Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Latest 25 from a total of 407 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Close Position | 15031644 | 1359 days ago | IN | 0 ETH | 0.00441151 | ||||
| Close Position | 14639917 | 1424 days ago | IN | 0 ETH | 0.00400909 | ||||
| Close Position | 14639912 | 1424 days ago | IN | 0 ETH | 0.00366256 | ||||
| Close Position | 14639905 | 1424 days ago | IN | 0 ETH | 0.00447865 | ||||
| Close Position | 14639897 | 1424 days ago | IN | 0 ETH | 0.00472943 | ||||
| Close Position | 14639896 | 1424 days ago | IN | 0 ETH | 0.00503125 | ||||
| Close Position | 14639893 | 1424 days ago | IN | 0 ETH | 0.00679438 | ||||
| Close Position | 14639879 | 1424 days ago | IN | 0 ETH | 0.00655811 | ||||
| Open Position | 14548071 | 1438 days ago | IN | 0 ETH | 0.01092683 | ||||
| Open Position | 14548050 | 1438 days ago | IN | 0 ETH | 0.01350157 | ||||
| Close Position | 14533199 | 1441 days ago | IN | 0 ETH | 0.01207218 | ||||
| Rebase | 14498025 | 1446 days ago | IN | 0 ETH | 0.00947956 | ||||
| Close Position | 14381993 | 1464 days ago | IN | 0 ETH | 0.00302709 | ||||
| Close Position | 14332309 | 1472 days ago | IN | 0 ETH | 0.00299585 | ||||
| Open Position | 14332288 | 1472 days ago | IN | 0 ETH | 0.0066381 | ||||
| Close Position | 14185091 | 1495 days ago | IN | 0 ETH | 0.00797565 | ||||
| Open Position | 14185085 | 1495 days ago | IN | 0 ETH | 0.0142053 | ||||
| Close Position | 14171782 | 1497 days ago | IN | 0 ETH | 0.00724592 | ||||
| Open Position | 14171252 | 1497 days ago | IN | 0 ETH | 0.01155529 | ||||
| Rebase | 14158334 | 1499 days ago | IN | 0 ETH | 0.00599377 | ||||
| Close Position | 14158167 | 1499 days ago | IN | 0 ETH | 0.00852298 | ||||
| Add Deposit | 14105784 | 1507 days ago | IN | 0 ETH | 0.00585422 | ||||
| Add Deposit | 14105764 | 1507 days ago | IN | 0 ETH | 0.00574692 | ||||
| Add Deposit | 14105753 | 1507 days ago | IN | 0 ETH | 0.00635422 | ||||
| Add Deposit | 14105753 | 1507 days ago | IN | 0 ETH | 0.00635422 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
Exchange
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
pragma abicoder v2;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./interfaces/IFluidity.sol";
import "./interfaces/ILiquidation.sol";
import "./interfaces/IExchange.sol";
import "./interfaces/IExchangeRates.sol";
import "./interfaces/IFundToken.sol";
import "./interfaces/ISystemSetting.sol";
import "./interfaces/IDepot.sol";
import "./utils/AddressResolver.sol";
import "./utils/BasicMaths.sol";
contract Exchange is AddressResolver, IExchange {
using SafeMath for uint;
using BasicMaths for uint;
using BasicMaths for bool;
using SafeERC20 for IERC20;
uint public _lastRebaseTime = 0;
uint private constant E18 = 1e18;
bytes32 private constant CONTRACT_FUNDTOKEN = "FundToken";
bytes32 private constant CONTRACT_EXCHANGERATES = "ExchangeRates";
bytes32 private constant CONTRACT_DEPOT = "Depot";
bytes32 private constant CONTRACT_SYSTEMSETTING = "SystemSetting";
bytes32 private constant CONTRACT_BASECURRENCY = "BaseCurrency";
function fundToken() internal view returns (address) {
return requireAndGetAddress(CONTRACT_FUNDTOKEN, "Missing FundToken Address");
}
function exchangeRates() internal view returns (IExchangeRates) {
return IExchangeRates(requireAndGetAddress(CONTRACT_EXCHANGERATES, "Missing ExchangeRates Address"));
}
function systemSetting() internal view returns (ISystemSetting) {
return ISystemSetting(requireAndGetAddress(CONTRACT_SYSTEMSETTING, "Missing SystemSetting Address"));
}
function depotAddress() internal view returns (address) {
return requireAndGetAddress(CONTRACT_DEPOT, "Missing Depot Address");
}
function getDepot() internal view returns (IDepot) {
return IDepot(depotAddress());
}
function baseCurrency() internal view returns (IERC20) {
return IERC20(requireAndGetAddress(CONTRACT_BASECURRENCY, "Missing BaseCurrency Address"));
}
function openPosition(bytes32 currencyKey, uint8 direction, uint16 level, uint position) external override returns (uint32) {
systemSetting().checkOpenPosition(position, level);
require(direction == 1 || direction == 2, "Direction Only Can Be 1 Or 2");
(uint32 currencyKeyIdx, uint openPrice) = exchangeRates().rateForCurrency(currencyKey);
uint32 index = getDepot().newPosition(msg.sender, openPrice, position, currencyKeyIdx, level, direction);
emit OpenPosition(msg.sender, index, openPrice, currencyKey, direction, level, position);
return index;
}
function addDeposit(uint32 positionId, uint margin) external override {
systemSetting().checkAddDeposit(margin);
getDepot().addDeposit(msg.sender, positionId, margin);
emit MarginCall(msg.sender, positionId, margin);
}
function closePosition(uint32 positionId) external override {
ISystemSetting setting = systemSetting();
setting.requireSystemActive();
IDepot depot = getDepot();
Position memory position;
(
position.account,
position.share,
position.leveragedPosition,
position.openPositionPrice,
position.currencyKeyIdx,
position.direction,
position.margin,
position.openRebaseLeft
) = depot.position(positionId);
require(position.account == msg.sender, "Position Not Match");
uint shareSubnetValue = position.share.mul(depot.netValue(position.direction)) / 1e18;
uint serviceFee = position.leveragedPosition.mul(setting.positionClosingFee()) / 1e18;
uint marginLoss = position.leveragedPosition.sub2Zero(shareSubnetValue);
uint rateForCurrency = exchangeRates().rateForCurrencyByIdx(position.currencyKeyIdx);
uint value = position.leveragedPosition.mul(rateForCurrency.diff(position.openPositionPrice)) / position.openPositionPrice;
bool isProfit = (rateForCurrency >= position.openPositionPrice) == (position.direction == 1);
if ( isProfit ) {
require(position.margin.add(value) > serviceFee.add(marginLoss), "Bankrupted Liquidation");
} else {
require(position.margin > value.add(serviceFee).add(marginLoss), "Bankrupted Liquidation");
}
depot.closePosition(
position,
positionId,
isProfit,
value,
marginLoss,
serviceFee);
emit ClosePosition(msg.sender, positionId, rateForCurrency, serviceFee, marginLoss, isProfit, value);
}
function rebase() external override {
IDepot depot = getDepot();
ISystemSetting setting = systemSetting();
uint time = block.timestamp;
require(_lastRebaseTime + setting.rebaseInterval() <= time, "Not Meet Rebase Interval");
require(depot.liquidityPool() > 0, "liquidity pool must more than 0");
(uint totalMarginLong, uint totalMarginShort, uint totalValueLong, uint totalValueShort) = depot.getTotalPositionState();
uint D = (totalValueLong.diff(totalValueShort)).mul(1e18) / depot.liquidityPool();
require(D > setting.imbalanceThreshold(), "not meet imbalance threshold");
uint lpd = depot.liquidityPool().mul(setting.imbalanceThreshold()) / 1e18;
uint r = totalValueLong.diff(totalValueShort).sub(lpd) / setting.rebaseRate();
uint rebaseLeft;
if(totalValueLong > totalValueShort) {
require(totalMarginLong >= r, "Long Margin Pool Has Bankrupted");
rebaseLeft = E18.sub(r.mul(1e18) / totalValueLong);
} else {
require(totalMarginShort >= r, "Short Margin Pool Has Bankrupted");
rebaseLeft = E18.sub(r.mul(1e18) / totalValueShort);
}
_lastRebaseTime = time;
depot.updateSubTotalState(totalValueLong > totalValueShort,
r.add(depot.liquidityPool()),
r, r, 0, rebaseLeft);
emit Rebase(time, r);
}
event OpenPosition(address indexed sender, uint32 positionId, uint price, bytes32 currencyKey, uint8 direction, uint16 level, uint position);
event MarginCall(address indexed sender, uint32 positionId, uint margin);
event ClosePosition(address indexed sender, uint32 positionId, uint price, uint serviceFee, uint marginLoss, bool isProfit, uint value);
event Rebase(uint time, uint r);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
pragma abicoder v2;
struct Position {
uint share; // decimals 18
uint openPositionPrice; // decimals 18
uint leveragedPosition; // decimals 6
uint margin; // decimals 6
uint openRebaseLeft; // decimals 18
address account;
uint32 currencyKeyIdx;
uint8 direction;
}
interface IDepot {
function initialFundingCompleted() external view returns (bool);
function liquidityPool() external view returns (uint);
function totalLeveragedPositions() external view returns (uint);
function totalValue() external view returns (uint);
function position(uint32 index) external view returns (
address account,
uint share,
uint leveragedPosition,
uint openPositionPrice,
uint32 currencyKeyIdx,
uint8 direction,
uint margin,
uint openRebaseLeft);
function netValue(uint8 direction) external view returns (uint);
function calMarginLoss(uint leveragedPosition, uint share, uint8 direction) external view returns (uint);
function calNetProfit(uint32 currencyKeyIdx,
uint leveragedPosition,
uint openPositionPrice,
uint8 direction) external view returns (bool, uint);
function completeInitialFunding() external;
function updateSubTotalState(bool isLong, uint liquidity, uint detaMargin,
uint detaLeveraged, uint detaShare, uint rebaseLeft) external;
function getTotalPositionState() external view returns (uint, uint, uint, uint);
function newPosition(
address account,
uint openPositionPrice,
uint margin,
uint32 currencyKeyIdx,
uint16 level,
uint8 direction) external returns (uint32);
function addDeposit(
address account,
uint32 positionId,
uint margin) external;
function liquidate(
Position memory position,
uint32 positionId,
bool isProfit,
uint fee,
uint value,
uint marginLoss,
uint liqReward,
address liquidator) external;
function bankruptedLiquidate(
Position memory position,
uint32 positionId,
uint liquidateFee,
uint marginLoss,
address liquidator) external;
function closePosition(
Position memory position,
uint32 positionId,
bool isProfit,
uint value,
uint marginLoss,
uint fee) external;
function addLiquidity(address account, uint value) external;
function withdrawLiquidity(address account, uint value) external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
interface IExchange {
function openPosition(bytes32 currencyKey, uint8 direction, uint16 leverage, uint position) external returns (uint32);
function addDeposit(uint32 positionId, uint margin) external;
function closePosition(uint32 positionId) external;
function rebase() external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
interface IExchangeRates {
function addCurrencyKey(bytes32 currencyKey_, address aggregator_) external;
function updateCurrencyKey(bytes32 currencyKey_, address aggregator_) external;
function deleteCurrencyKey(bytes32 currencyKey) external;
function rateForCurrency(bytes32 currencyKey) external view returns (uint32, uint);
function rateForCurrencyByIdx(uint32 idx) external view returns (uint);
function currencyKeyExist(bytes32 currencyKey) external view returns (bool);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
interface IFluidity {
function initialFunding(uint value) external;
function closeInitialFunding() external;
function fundLiquidity(uint value) external;
function withdrawLiquidity(uint value) external;
function fundTokenPrice() external view returns (uint);
function availableToFund() external view returns (uint);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
interface IFundToken {
function mint(address account, uint value) external;
function burn(address account, uint value) external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
interface ILiquidation {
function liquidate(uint32 positionId) external;
function bankruptedLiquidate(uint32 positionId) external;
function alertLiquidation(uint32 positionId) external view returns (bool);
function alertBankruptedLiquidation(uint32 positionId) external view returns (bool);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
interface ISystemSetting {
// maxInitialLiquidityFunding
function maxInitialLiquidityFunding() external view returns (uint256);
// constantMarginRatio
function constantMarginRatio() external view returns (uint256);
// leverageExist
function leverageExist(uint32 leverage_) external view returns (bool);
// minInitialMargin
function minInitialMargin() external view returns (uint256);
// minAddDeposit
function minAddDeposit() external view returns (uint256);
// minHoldingPeriod
function minHoldingPeriod() external view returns (uint);
// marginRatio
function marginRatio() external view returns (uint256);
// positionClosingFee
function positionClosingFee() external view returns (uint256);
// liquidationFee
function liquidationFee() external view returns (uint256);
// rebaseInterval
function rebaseInterval() external view returns (uint);
// rebaseRate
function rebaseRate() external view returns (uint);
// imbalanceThreshold
function imbalanceThreshold() external view returns (uint);
// minFundTokenRequired
function minFundTokenRequired() external view returns (uint);
function checkOpenPosition(uint position, uint16 level) external view;
function checkAddDeposit(uint margin) external view;
function requireSystemActive() external;
function resumeSystem() external;
function suspendSystem() external;
event Suspend(address indexed sender);
event Resume(address indexed sender);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
import "@openzeppelin/contracts/access/Ownable.sol";
contract AddressResolver is Ownable {
mapping(bytes32 => address) public repository;
function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner {
require(names.length == destinations.length, "Input lengths must match");
for (uint i = 0; i < names.length; i++) {
repository[names[i]] = destinations[i];
}
}
function requireAndGetAddress(bytes32 name, string memory reason) internal view returns (address) {
address _foundAddress = repository[name];
require(_foundAddress != address(0), reason);
return _foundAddress;
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
import "@openzeppelin/contracts/math/SafeMath.sol";
library BasicMaths {
/**
* @dev Returns the abs of substraction of two unsigned integers
*
* _Available since v3.4._
*/
function diff(uint256 a, uint256 b) internal pure returns (uint256) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
/**
* @dev Returns a - b if a > b, else return 0
*
* _Available since v3.4._
*/
function sub2Zero(uint256 a, uint256 b) internal pure returns (uint256) {
if (a > b) {
return a - b;
} else {
return 0;
}
}
/**
* @dev if isSub then Returns a - b, else return a + b
*
* _Available since v3.4._
*/
function addOrSub(bool isAdd, uint256 a, uint256 b) internal pure returns (uint256) {
if (isAdd) {
return SafeMath.add(a, b);
} else {
return SafeMath.sub(a, b);
}
}
/**
* @dev if isSub then Returns sub2Zero(a, b), else return a + b
*
* _Available since v3.4._
*/
function addOrSub2Zero(bool isAdd, uint256 a, uint256 b) internal pure returns (uint256) {
if (isAdd) {
return SafeMath.add(a, b);
} else {
if (a > b) {
return a - b;
} else {
return 0;
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @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, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @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) internal 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) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @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) internal pure returns (uint256) {
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, reverting 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) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting 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) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* 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) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* 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) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}{
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "istanbul",
"libraries": {},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint32","name":"positionId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"serviceFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marginLoss","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isProfit","type":"bool"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"ClosePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint32","name":"positionId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"margin","type":"uint256"}],"name":"MarginCall","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint32","name":"positionId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"uint8","name":"direction","type":"uint8"},{"indexed":false,"internalType":"uint16","name":"level","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"position","type":"uint256"}],"name":"OpenPosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"r","type":"uint256"}],"name":"Rebase","type":"event"},{"inputs":[],"name":"_lastRebaseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"positionId","type":"uint32"},{"internalType":"uint256","name":"margin","type":"uint256"}],"name":"addDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"positionId","type":"uint32"}],"name":"closePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"names","type":"bytes32[]"},{"internalType":"address[]","name":"destinations","type":"address[]"}],"name":"importAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"internalType":"uint8","name":"direction","type":"uint8"},{"internalType":"uint16","name":"level","type":"uint16"},{"internalType":"uint256","name":"position","type":"uint256"}],"name":"openPosition","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"repository","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6080604052600060025534801561001557600080fd5b50600061002061006f565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350610073565b3390565b611cf6806100826000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b14610111578063ab0b8f7714610119578063af14052c1461012c578063e1fff61f14610134578063f2fde38b146101545761009e565b8063187f7935146100a357806351f954bf146100cc578063715018a6146100e15780637715dd4d146100e957806381495710146100fc575b600080fd5b6100b66100b136600461173e565b610167565b6040516100c39190611890565b60405180910390f35b6100df6100da3660046117f0565b610182565b005b6100df610629565b6100df6100f7366004611828565b6106e7565b6101046107fa565b6040516100c39190611935565b6100b6610800565b6100df6101273660046116d5565b61080f565b6100df610954565b610147610142366004611756565b610f91565b6040516100c39190611ba2565b6100df61016236600461163e565b61119b565b6001602052600090815260409020546001600160a01b031681565b600061018c6112af565b9050806001600160a01b031663086dabd16040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156101c957600080fd5b505af11580156101dd573d6000803e3d6000fd5b5050505060006101eb611305565b90506101f561159e565b60405163f77fc80160e01b81526001600160a01b0383169063f77fc80190610221908790600401611ba2565b6101006040518083038186803b15801561023a57600080fd5b505afa15801561024e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610272919061165a565b6080890152606088015260ff1660e087015263ffffffff1660c08601526020850152604084015282526001600160a01b031660a0820181905233146102d25760405162461bcd60e51b81526004016102c990611ab6565b60405180910390fd5b6000670de0b6b3a7640000610368846001600160a01b031663739039f18560e001516040518263ffffffff1660e01b81526004016103109190611c32565b60206040518083038186803b15801561032857600080fd5b505afa15801561033c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036091906117a3565b84519061130f565b8161036f57fe5b0490506000670de0b6b3a76400006103fc866001600160a01b031663292b63a86040518163ffffffff1660e01b815260040160206040518083038186803b1580156103b957600080fd5b505afa1580156103cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f191906117a3565b60408601519061130f565b8161040357fe5b049050600061041f83856040015161137190919063ffffffff16565b9050600061042b61138c565b6001600160a01b03166316d71eb68660c001516040518263ffffffff1660e01b815260040161045a9190611ba2565b60206040518083038186803b15801561047257600080fd5b505afa158015610486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104aa91906117a3565b60208601519091506000906104cd6104c284836113dd565b60408901519061130f565b816104d457fe5b04905060008660e0015160ff1660011415158760200151841015151514905080156105345761050385856113f8565b606088015161051290846113f8565b1161052f5760405162461bcd60e51b81526004016102c990611a86565b61056a565b6105488461054284886113f8565b906113f8565b87606001511161056a5760405162461bcd60e51b81526004016102c990611a86565b604051631b840ed760e11b81526001600160a01b038916906337081dae906105a0908a908e90869088908b908d90600401611ae2565b600060405180830381600087803b1580156105ba57600080fd5b505af11580156105ce573d6000803e3d6000fd5b50505050336001600160a01b03167fe3908c692348f2511672c034ea1462b7c8f90f0a24bb9a5fefaa6efdcfd9c2d98b858888868860405161061596959493929190611c00565b60405180910390a250505050505050505050565b610631611452565b6001600160a01b0316610642610800565b6001600160a01b03161461069d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6106ef6112af565b6001600160a01b0316635e58685e826040518263ffffffff1660e01b815260040161071a9190611935565b60006040518083038186803b15801561073257600080fd5b505afa158015610746573d6000803e3d6000fd5b50505050610752611305565b6001600160a01b0316631e5ffd693384846040518463ffffffff1660e01b8152600401610781939291906118e4565b600060405180830381600087803b15801561079b57600080fd5b505af11580156107af573d6000803e3d6000fd5b50505050336001600160a01b03167f4b51eca45b3849a44b2d78b44b600b65b92ce53a53b3f652f75f3f227a5988b983836040516107ee929190611bb3565b60405180910390a25050565b60025481565b6000546001600160a01b031690565b610817611452565b6001600160a01b0316610828610800565b6001600160a01b031614610883576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8281146108d7576040805162461bcd60e51b815260206004820152601860248201527f496e707574206c656e67746873206d757374206d617463680000000000000000604482015290519081900360640190fd5b60005b8381101561094d578282828181106108ee57fe5b905060200201356001600160a01b03166001600087878581811061090e57fe5b6020908102929092013583525081019190915260400160002080546001600160a01b0319166001600160a01b03929092169190911790556001016108da565b5050505050565b600061095e611305565b9050600061096a6112af565b9050600042905080826001600160a01b03166389edeb746040518163ffffffff1660e01b815260040160206040518083038186803b1580156109ab57600080fd5b505afa1580156109bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e391906117a3565b600254011115610a055760405162461bcd60e51b81526004016102c990611975565b6000836001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a4057600080fd5b505afa158015610a54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7891906117a3565b11610a955760405162461bcd60e51b81526004016102c99061193e565b600080600080866001600160a01b031663120089ff6040518163ffffffff1660e01b815260040160806040518083038186803b158015610ad457600080fd5b505afa158015610ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0c91906117bb565b93509350935093506000876001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b4f57600080fd5b505afa158015610b63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8791906117a3565b610ba3670de0b6b3a7640000610b9d86866113dd565b9061130f565b81610baa57fe5b049050866001600160a01b031663fa8b9a096040518163ffffffff1660e01b815260040160206040518083038186803b158015610be657600080fd5b505afa158015610bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1e91906117a3565b8111610c3c5760405162461bcd60e51b81526004016102c9906119e3565b6000670de0b6b3a7640000610d2c896001600160a01b031663fa8b9a096040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8357600080fd5b505afa158015610c97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbb91906117a3565b8b6001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cf457600080fd5b505afa158015610d08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9d91906117a3565b81610d3357fe5b0490506000886001600160a01b0316637cb95d006040518163ffffffff1660e01b815260040160206040518083038186803b158015610d7157600080fd5b505afa158015610d85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da991906117a3565b610dbd83610db788886113dd565b90611456565b81610dc457fe5b049050600084861115610e265781881015610df15760405162461bcd60e51b81526004016102c9906119ac565b610e1f86610e0784670de0b6b3a764000061130f565b81610e0e57fe5b670de0b6b3a7640000919004611456565b9050610e5f565b81871015610e465760405162461bcd60e51b81526004016102c990611a51565b610e5c85610e0784670de0b6b3a764000061130f565b90505b886002819055508a6001600160a01b03166338dcc48a868811610ef38e6001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610eb457600080fd5b505afa158015610ec8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eec91906117a3565b86906113f8565b85866000876040518763ffffffff1660e01b8152600401610f199695949392919061190b565b600060405180830381600087803b158015610f3357600080fd5b505af1158015610f47573d6000803e3d6000fd5b505050507f11c6bf55864ff83827df712625d7a80e5583eef0264921025e7cd22003a215118983604051610f7c929190611b94565b60405180910390a15050505050505050505050565b6000610f9b6112af565b6001600160a01b031663a0d07b7b83856040518363ffffffff1660e01b8152600401610fc8929190611b82565b60006040518083038186803b158015610fe057600080fd5b505afa158015610ff4573d6000803e3d6000fd5b505050508360ff166001148061100d57508360ff166002145b6110295760405162461bcd60e51b81526004016102c990611a1a565b60008061103461138c565b6001600160a01b031663ac82f608886040518263ffffffff1660e01b815260040161105f9190611935565b604080518083038186803b15801561107657600080fd5b505afa15801561108a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ae9190611853565b9150915060006110bc611305565b6001600160a01b0316637e94cc79338488878b8d6040518763ffffffff1660e01b81526004016110f1969594939291906118a4565b602060405180830381600087803b15801561110b57600080fd5b505af115801561111f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611143919061180c565b9050336001600160a01b03167f1087889fe47e2598624d6476719fd6d0f0b247ccbb06e8bf31a0694efda3402082848b8b8b8b60405161118896959493929190611bc9565b60405180910390a2979650505050505050565b6111a3611452565b6001600160a01b03166111b4610800565b6001600160a01b03161461120f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166112545760405162461bcd60e51b8152600401808060200182810382526026815260200180611c7a6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006113006c53797374656d53657474696e6760981b6040518060400160405280601d81526020017f4d697373696e672053797374656d53657474696e6720416464726573730000008152506114b3565b905090565b600061130061155d565b60008261131e5750600061136b565b8282028284828161132b57fe5b04146113685760405162461bcd60e51b8152600401808060200182810382526021815260200180611ca06021913960400191505060405180910390fd5b90505b92915050565b600081831115611384575080820361136b565b50600061136b565b60006113006c45786368616e6765526174657360981b6040518060400160405280601d81526020017f4d697373696e672045786368616e6765526174657320416464726573730000008152506114b3565b60008183106113ef575080820361136b565b5081810361136b565b600082820183811015611368576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b6000828211156114ad576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000828152600160205260408120546001600160a01b031682816115555760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561151a578181015183820152602001611502565b50505050905090810190601f1680156115475780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b509392505050565b60006113006411195c1bdd60da1b604051806040016040528060158152602001744d697373696e67204465706f74204164647265737360581b8152506114b3565b604051806101000160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600063ffffffff168152602001600060ff1681525090565b60008083601f840112611606578182fd5b50813567ffffffffffffffff81111561161d578182fd5b602083019150836020808302850101111561163757600080fd5b9250929050565b60006020828403121561164f578081fd5b813561136881611c40565b600080600080600080600080610100898b031215611676578384fd5b885161168181611c40565b8098505060208901519650604089015195506060890151945060808901516116a881611c58565b60a08a01519094506116b981611c6a565b60c08a015160e0909a0151989b979a5095989497939692505050565b600080600080604085870312156116ea578384fd5b843567ffffffffffffffff80821115611701578586fd5b61170d888389016115f5565b90965094506020870135915080821115611725578384fd5b50611732878288016115f5565b95989497509550505050565b60006020828403121561174f578081fd5b5035919050565b6000806000806080858703121561176b578384fd5b84359350602085013561177d81611c6a565b9250604085013561ffff81168114611793578283fd5b9396929550929360600135925050565b6000602082840312156117b4578081fd5b5051919050565b600080600080608085870312156117d0578384fd5b505082516020840151604085015160609095015191969095509092509050565b600060208284031215611801578081fd5b813561136881611c58565b60006020828403121561181d578081fd5b815161136881611c58565b6000806040838503121561183a578182fd5b823561184581611c58565b946020939093013593505050565b60008060408385031215611865578182fd5b825161187081611c58565b6020939093015192949293505050565b15159052565b63ffffffff169052565b6001600160a01b0391909116815260200190565b6001600160a01b039690961686526020860194909452604085019290925263ffffffff16606084015261ffff16608083015260ff1660a082015260c00190565b6001600160a01b0393909316835263ffffffff919091166020830152604082015260600190565b9515158652602086019490945260408501929092526060840152608083015260a082015260c00190565b90815260200190565b6020808252601f908201527f6c697175696469747920706f6f6c206d757374206d6f7265207468616e203000604082015260600190565b60208082526018908201527f4e6f74204d6565742052656261736520496e74657276616c0000000000000000604082015260600190565b6020808252601f908201527f4c6f6e67204d617267696e20506f6f6c204861732042616e6b72757074656400604082015260600190565b6020808252601c908201527f6e6f74206d65657420696d62616c616e6365207468726573686f6c6400000000604082015260600190565b6020808252601c908201527f446972656374696f6e204f6e6c792043616e2042652031204f72203200000000604082015260600190565b6020808252818101527f53686f7274204d617267696e20506f6f6c204861732042616e6b727570746564604082015260600190565b6020808252601690820152752130b735b93ab83a32b2102634b8bab4b230ba34b7b760511b604082015260600190565b6020808252601290820152710a0dee6d2e8d2dedc409cdee8409ac2e8c6d60731b604082015260600190565b60006101a082019050875182526020880151602083015260408801516040830152606088015160608301526080880151608083015260018060a01b0360a08901511660a083015263ffffffff60c08901511660c083015260ff60e08901511660e0830152611b54610100830188611886565b611b62610120830187611880565b846101408301528361016083015282610180830152979650505050505050565b91825261ffff16602082015260400190565b918252602082015260400190565b63ffffffff91909116815260200190565b63ffffffff929092168252602082015260400190565b63ffffffff9690961686526020860194909452604085019290925260ff16606084015261ffff16608083015260a082015260c00190565b63ffffffff9690961686526020860194909452604085019290925260608401521515608083015260a082015260c00190565b60ff91909116815260200190565b6001600160a01b0381168114611c5557600080fd5b50565b63ffffffff81168114611c5557600080fd5b60ff81168114611c5557600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122018f7b24cb1e1a33be495ae466c427604afe963373b2a38cf609dd7b82c997fc964736f6c63430007060033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b14610111578063ab0b8f7714610119578063af14052c1461012c578063e1fff61f14610134578063f2fde38b146101545761009e565b8063187f7935146100a357806351f954bf146100cc578063715018a6146100e15780637715dd4d146100e957806381495710146100fc575b600080fd5b6100b66100b136600461173e565b610167565b6040516100c39190611890565b60405180910390f35b6100df6100da3660046117f0565b610182565b005b6100df610629565b6100df6100f7366004611828565b6106e7565b6101046107fa565b6040516100c39190611935565b6100b6610800565b6100df6101273660046116d5565b61080f565b6100df610954565b610147610142366004611756565b610f91565b6040516100c39190611ba2565b6100df61016236600461163e565b61119b565b6001602052600090815260409020546001600160a01b031681565b600061018c6112af565b9050806001600160a01b031663086dabd16040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156101c957600080fd5b505af11580156101dd573d6000803e3d6000fd5b5050505060006101eb611305565b90506101f561159e565b60405163f77fc80160e01b81526001600160a01b0383169063f77fc80190610221908790600401611ba2565b6101006040518083038186803b15801561023a57600080fd5b505afa15801561024e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610272919061165a565b6080890152606088015260ff1660e087015263ffffffff1660c08601526020850152604084015282526001600160a01b031660a0820181905233146102d25760405162461bcd60e51b81526004016102c990611ab6565b60405180910390fd5b6000670de0b6b3a7640000610368846001600160a01b031663739039f18560e001516040518263ffffffff1660e01b81526004016103109190611c32565b60206040518083038186803b15801561032857600080fd5b505afa15801561033c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036091906117a3565b84519061130f565b8161036f57fe5b0490506000670de0b6b3a76400006103fc866001600160a01b031663292b63a86040518163ffffffff1660e01b815260040160206040518083038186803b1580156103b957600080fd5b505afa1580156103cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f191906117a3565b60408601519061130f565b8161040357fe5b049050600061041f83856040015161137190919063ffffffff16565b9050600061042b61138c565b6001600160a01b03166316d71eb68660c001516040518263ffffffff1660e01b815260040161045a9190611ba2565b60206040518083038186803b15801561047257600080fd5b505afa158015610486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104aa91906117a3565b60208601519091506000906104cd6104c284836113dd565b60408901519061130f565b816104d457fe5b04905060008660e0015160ff1660011415158760200151841015151514905080156105345761050385856113f8565b606088015161051290846113f8565b1161052f5760405162461bcd60e51b81526004016102c990611a86565b61056a565b6105488461054284886113f8565b906113f8565b87606001511161056a5760405162461bcd60e51b81526004016102c990611a86565b604051631b840ed760e11b81526001600160a01b038916906337081dae906105a0908a908e90869088908b908d90600401611ae2565b600060405180830381600087803b1580156105ba57600080fd5b505af11580156105ce573d6000803e3d6000fd5b50505050336001600160a01b03167fe3908c692348f2511672c034ea1462b7c8f90f0a24bb9a5fefaa6efdcfd9c2d98b858888868860405161061596959493929190611c00565b60405180910390a250505050505050505050565b610631611452565b6001600160a01b0316610642610800565b6001600160a01b03161461069d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6106ef6112af565b6001600160a01b0316635e58685e826040518263ffffffff1660e01b815260040161071a9190611935565b60006040518083038186803b15801561073257600080fd5b505afa158015610746573d6000803e3d6000fd5b50505050610752611305565b6001600160a01b0316631e5ffd693384846040518463ffffffff1660e01b8152600401610781939291906118e4565b600060405180830381600087803b15801561079b57600080fd5b505af11580156107af573d6000803e3d6000fd5b50505050336001600160a01b03167f4b51eca45b3849a44b2d78b44b600b65b92ce53a53b3f652f75f3f227a5988b983836040516107ee929190611bb3565b60405180910390a25050565b60025481565b6000546001600160a01b031690565b610817611452565b6001600160a01b0316610828610800565b6001600160a01b031614610883576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8281146108d7576040805162461bcd60e51b815260206004820152601860248201527f496e707574206c656e67746873206d757374206d617463680000000000000000604482015290519081900360640190fd5b60005b8381101561094d578282828181106108ee57fe5b905060200201356001600160a01b03166001600087878581811061090e57fe5b6020908102929092013583525081019190915260400160002080546001600160a01b0319166001600160a01b03929092169190911790556001016108da565b5050505050565b600061095e611305565b9050600061096a6112af565b9050600042905080826001600160a01b03166389edeb746040518163ffffffff1660e01b815260040160206040518083038186803b1580156109ab57600080fd5b505afa1580156109bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e391906117a3565b600254011115610a055760405162461bcd60e51b81526004016102c990611975565b6000836001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a4057600080fd5b505afa158015610a54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7891906117a3565b11610a955760405162461bcd60e51b81526004016102c99061193e565b600080600080866001600160a01b031663120089ff6040518163ffffffff1660e01b815260040160806040518083038186803b158015610ad457600080fd5b505afa158015610ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0c91906117bb565b93509350935093506000876001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b4f57600080fd5b505afa158015610b63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8791906117a3565b610ba3670de0b6b3a7640000610b9d86866113dd565b9061130f565b81610baa57fe5b049050866001600160a01b031663fa8b9a096040518163ffffffff1660e01b815260040160206040518083038186803b158015610be657600080fd5b505afa158015610bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1e91906117a3565b8111610c3c5760405162461bcd60e51b81526004016102c9906119e3565b6000670de0b6b3a7640000610d2c896001600160a01b031663fa8b9a096040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8357600080fd5b505afa158015610c97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbb91906117a3565b8b6001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cf457600080fd5b505afa158015610d08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9d91906117a3565b81610d3357fe5b0490506000886001600160a01b0316637cb95d006040518163ffffffff1660e01b815260040160206040518083038186803b158015610d7157600080fd5b505afa158015610d85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da991906117a3565b610dbd83610db788886113dd565b90611456565b81610dc457fe5b049050600084861115610e265781881015610df15760405162461bcd60e51b81526004016102c9906119ac565b610e1f86610e0784670de0b6b3a764000061130f565b81610e0e57fe5b670de0b6b3a7640000919004611456565b9050610e5f565b81871015610e465760405162461bcd60e51b81526004016102c990611a51565b610e5c85610e0784670de0b6b3a764000061130f565b90505b886002819055508a6001600160a01b03166338dcc48a868811610ef38e6001600160a01b031663665a11ca6040518163ffffffff1660e01b815260040160206040518083038186803b158015610eb457600080fd5b505afa158015610ec8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eec91906117a3565b86906113f8565b85866000876040518763ffffffff1660e01b8152600401610f199695949392919061190b565b600060405180830381600087803b158015610f3357600080fd5b505af1158015610f47573d6000803e3d6000fd5b505050507f11c6bf55864ff83827df712625d7a80e5583eef0264921025e7cd22003a215118983604051610f7c929190611b94565b60405180910390a15050505050505050505050565b6000610f9b6112af565b6001600160a01b031663a0d07b7b83856040518363ffffffff1660e01b8152600401610fc8929190611b82565b60006040518083038186803b158015610fe057600080fd5b505afa158015610ff4573d6000803e3d6000fd5b505050508360ff166001148061100d57508360ff166002145b6110295760405162461bcd60e51b81526004016102c990611a1a565b60008061103461138c565b6001600160a01b031663ac82f608886040518263ffffffff1660e01b815260040161105f9190611935565b604080518083038186803b15801561107657600080fd5b505afa15801561108a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ae9190611853565b9150915060006110bc611305565b6001600160a01b0316637e94cc79338488878b8d6040518763ffffffff1660e01b81526004016110f1969594939291906118a4565b602060405180830381600087803b15801561110b57600080fd5b505af115801561111f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611143919061180c565b9050336001600160a01b03167f1087889fe47e2598624d6476719fd6d0f0b247ccbb06e8bf31a0694efda3402082848b8b8b8b60405161118896959493929190611bc9565b60405180910390a2979650505050505050565b6111a3611452565b6001600160a01b03166111b4610800565b6001600160a01b03161461120f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166112545760405162461bcd60e51b8152600401808060200182810382526026815260200180611c7a6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006113006c53797374656d53657474696e6760981b6040518060400160405280601d81526020017f4d697373696e672053797374656d53657474696e6720416464726573730000008152506114b3565b905090565b600061130061155d565b60008261131e5750600061136b565b8282028284828161132b57fe5b04146113685760405162461bcd60e51b8152600401808060200182810382526021815260200180611ca06021913960400191505060405180910390fd5b90505b92915050565b600081831115611384575080820361136b565b50600061136b565b60006113006c45786368616e6765526174657360981b6040518060400160405280601d81526020017f4d697373696e672045786368616e6765526174657320416464726573730000008152506114b3565b60008183106113ef575080820361136b565b5081810361136b565b600082820183811015611368576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b6000828211156114ad576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000828152600160205260408120546001600160a01b031682816115555760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561151a578181015183820152602001611502565b50505050905090810190601f1680156115475780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b509392505050565b60006113006411195c1bdd60da1b604051806040016040528060158152602001744d697373696e67204465706f74204164647265737360581b8152506114b3565b604051806101000160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600063ffffffff168152602001600060ff1681525090565b60008083601f840112611606578182fd5b50813567ffffffffffffffff81111561161d578182fd5b602083019150836020808302850101111561163757600080fd5b9250929050565b60006020828403121561164f578081fd5b813561136881611c40565b600080600080600080600080610100898b031215611676578384fd5b885161168181611c40565b8098505060208901519650604089015195506060890151945060808901516116a881611c58565b60a08a01519094506116b981611c6a565b60c08a015160e0909a0151989b979a5095989497939692505050565b600080600080604085870312156116ea578384fd5b843567ffffffffffffffff80821115611701578586fd5b61170d888389016115f5565b90965094506020870135915080821115611725578384fd5b50611732878288016115f5565b95989497509550505050565b60006020828403121561174f578081fd5b5035919050565b6000806000806080858703121561176b578384fd5b84359350602085013561177d81611c6a565b9250604085013561ffff81168114611793578283fd5b9396929550929360600135925050565b6000602082840312156117b4578081fd5b5051919050565b600080600080608085870312156117d0578384fd5b505082516020840151604085015160609095015191969095509092509050565b600060208284031215611801578081fd5b813561136881611c58565b60006020828403121561181d578081fd5b815161136881611c58565b6000806040838503121561183a578182fd5b823561184581611c58565b946020939093013593505050565b60008060408385031215611865578182fd5b825161187081611c58565b6020939093015192949293505050565b15159052565b63ffffffff169052565b6001600160a01b0391909116815260200190565b6001600160a01b039690961686526020860194909452604085019290925263ffffffff16606084015261ffff16608083015260ff1660a082015260c00190565b6001600160a01b0393909316835263ffffffff919091166020830152604082015260600190565b9515158652602086019490945260408501929092526060840152608083015260a082015260c00190565b90815260200190565b6020808252601f908201527f6c697175696469747920706f6f6c206d757374206d6f7265207468616e203000604082015260600190565b60208082526018908201527f4e6f74204d6565742052656261736520496e74657276616c0000000000000000604082015260600190565b6020808252601f908201527f4c6f6e67204d617267696e20506f6f6c204861732042616e6b72757074656400604082015260600190565b6020808252601c908201527f6e6f74206d65657420696d62616c616e6365207468726573686f6c6400000000604082015260600190565b6020808252601c908201527f446972656374696f6e204f6e6c792043616e2042652031204f72203200000000604082015260600190565b6020808252818101527f53686f7274204d617267696e20506f6f6c204861732042616e6b727570746564604082015260600190565b6020808252601690820152752130b735b93ab83a32b2102634b8bab4b230ba34b7b760511b604082015260600190565b6020808252601290820152710a0dee6d2e8d2dedc409cdee8409ac2e8c6d60731b604082015260600190565b60006101a082019050875182526020880151602083015260408801516040830152606088015160608301526080880151608083015260018060a01b0360a08901511660a083015263ffffffff60c08901511660c083015260ff60e08901511660e0830152611b54610100830188611886565b611b62610120830187611880565b846101408301528361016083015282610180830152979650505050505050565b91825261ffff16602082015260400190565b918252602082015260400190565b63ffffffff91909116815260200190565b63ffffffff929092168252602082015260400190565b63ffffffff9690961686526020860194909452604085019290925260ff16606084015261ffff16608083015260a082015260c00190565b63ffffffff9690961686526020860194909452604085019290925260608401521515608083015260a082015260c00190565b60ff91909116815260200190565b6001600160a01b0381168114611c5557600080fd5b50565b63ffffffff81168114611c5557600080fd5b60ff81168114611c5557600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122018f7b24cb1e1a33be495ae466c427604afe963373b2a38cf609dd7b82c997fc964736f6c63430007060033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
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.