Source Code
Overview
MON Balance
MON Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Loading...
Loading
Contract Name:
Swapper
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {
SafeERC20
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {
IUniswapV2Router02
} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import {
IUniswapV2Factory
} from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import {BuyBackStore} from "./BuyBackStore.sol";
import {FundStore} from "./FundStore.sol";
import {DataStore} from "./DataStore.sol";
import "./Roles.sol";
interface IWrappedNative {
function deposit() external payable;
function withdraw(uint256) external;
}
/// @title Swapper
/// @notice Swaps tokens for base token
contract Swapper is Roles {
using SafeERC20 for IERC20;
// Constants for unit and BPS divider
uint256 public constant UNIT = 10 ** 18;
uint256 public constant BPS_DIVIDER = 10000;
IERC20 public Pingu;
address public WNative;
IUniswapV2Router02 public router;
IUniswapV2Factory public factory;
DataStore public DS;
FundStore public fundStore;
BuyBackStore public buyBackStore;
mapping(address => uint256) public minAmount;
address[] public routeHints;
// Custom ReentrancyGuard
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
uint256 public maxSlippageBps;
// Events
event RouterUpdated(
address indexed previousRouter,
address indexed newRouter
);
event FactoryUpdated(
address indexed previousFactory,
address indexed newFactory
);
event WNativeUpdated(
address indexed previousWNative,
address indexed newWNative
);
event MinAmountUpdated(address indexed token, uint256 minAmount);
event TokensSwapped(
address indexed caller,
address indexed tokenIn,
uint256 amountIn,
uint256 amountOut
);
event RewardPaid(
address indexed caller,
address indexed token,
uint256 amount
);
event MaxSlippageUpdated(uint256 indexed newMaxSlippageBps);
/// @notice Modifier to prevent reentrancy
modifier nonReentrant() {
require(_status != _ENTERED, "Swapper: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
/// @notice Initialize the Swapper
/// @param _router The address of the router
/// @param ds The address of the DataStore
/// @param rs The address of the RoleStore
function initialize(
address _router,
address ds,
address rs
) external initializer {
require(_router != address(0), "Swapper: router is zero");
require(
Address.isContract(_router),
"Swapper: router must be a contract"
);
DS = DataStore(ds);
roleStore = RoleStore(rs);
_setGov(msg.sender);
_status = _NOT_ENTERED;
router = IUniswapV2Router02(_router);
Pingu = IERC20(DS.getAddress("PINGU"));
_syncRouterDeps(_router);
}
/// @notice Link the Swapper to the protocol contracts
/// @dev Only callable by governance
function link() external onlyGov {
fundStore = FundStore(DS.getAddress("FundStore"));
buyBackStore = BuyBackStore(DS.getAddress("BuyBackStore"));
Pingu = IERC20(DS.getAddress("PINGU"));
_approveTokenIfNeeded(
address(Pingu),
address(fundStore),
type(uint256).max
);
}
/// @notice Set the max slippage in bps
/// @param newMaxSlippageBps The new max slippage in bps
/// @dev Only callable by governance
function setMaxSlippageBps(uint256 newMaxSlippageBps) external onlyGov {
require(
newMaxSlippageBps <= BPS_DIVIDER,
"Swapper: max slippage must be less than or equal to 100%"
);
maxSlippageBps = newMaxSlippageBps;
emit MaxSlippageUpdated(newMaxSlippageBps);
}
/// @notice Set the router
/// @param newRouter The address of the new router
/// @dev Only callable by governance
function setRouter(address newRouter) external onlyGov {
require(newRouter != address(0), "Swapper: router is zero");
require(
Address.isContract(newRouter),
"Swapper: router must be a contract"
);
emit RouterUpdated(address(router), newRouter);
router = IUniswapV2Router02(newRouter);
_syncRouterDeps(newRouter);
}
/// @notice Set the minimum amount for a token
/// @param token The address of the token
/// @param amount The minimum amount
/// @dev Only callable by governance
function setMinAmount(address token, uint256 amount) external onlyGov {
minAmount[token] = amount;
emit MinAmountUpdated(token, amount);
}
/// @notice Set the minimum amounts for a tokens
/// @param tokens The addresses of the tokens
/// @param amounts The minimum amounts
/// @dev Only callable by governance
function setMinAmounts(
address[] calldata tokens,
uint256[] calldata amounts
) external onlyGov {
require(
tokens.length == amounts.length,
"Swapper: array length mismatch"
);
for (uint256 i = 0; i < tokens.length; i++) {
minAmount[tokens[i]] = amounts[i];
emit MinAmountUpdated(tokens[i], amounts[i]);
}
}
/// @notice Set the route hints
/// @param tokens The addresses of the tokens
/// @dev Only callable by governance
function setRouteHints(address[] calldata tokens) external onlyGov {
delete routeHints;
for (uint256 i = 0; i < tokens.length; i++) {
require(tokens[i] != address(0), "Swapper: zero hint");
routeHints.push(tokens[i]);
}
}
/// @notice Swap tokens for base token automatically
/// @param tokensIn The addresses of the tokens in
/// @param userAddress The address of the user
/// @return totalBaseOut The total amount of base token out
/// @dev Only callable by a contract
function swapTokensForBaseAuto(
address[] calldata tokensIn,
address userAddress
) external onlyContract nonReentrant returns (uint256 totalBaseOut) {
uint256 buyBackReward = buyBackStore.getBuyBackReward();
for (uint256 i = 0; i < tokensIn.length; i++) {
address tokenIn = tokensIn[i];
address inputToken = tokenIn == address(0) ? WNative : tokenIn;
uint256 min = minAmount[inputToken];
if (min == 0) continue;
uint256 candidate = buyBackStore.getAssetBalance(tokenIn);
if (candidate < min) continue;
address[] memory path = _computePath(inputToken);
if (path.length == 0) continue;
uint256 buyBackRewardAmount = (buyBackReward * candidate) /
BPS_DIVIDER;
uint256 amountIn = candidate - buyBackRewardAmount;
if (amountIn == 0) continue;
uint256 amountOutMin = 0;
if (maxSlippageBps > 0) {
try router.getAmountsOut(amountIn, path) returns (
uint256[] memory amountsOut
) {
uint256 expectedOut = amountsOut[amountsOut.length - 1];
if (expectedOut == 0) {
continue;
}
amountOutMin =
(expectedOut * (BPS_DIVIDER - maxSlippageBps)) /
BPS_DIVIDER;
if (amountOutMin == 0) {
continue;
}
} catch {
continue;
}
}
fundStore.transferOut(tokenIn, address(this), amountIn);
if (tokenIn == address(0)) {
IWrappedNative(WNative).deposit{value: amountIn}();
}
_approveTokenIfNeeded(inputToken, address(router), amountIn);
bool swapSucceeded = false;
uint256 received = 0;
try
router.swapExactTokensForTokens(
amountIn,
amountOutMin,
path,
address(this),
block.timestamp + 5 minutes
)
returns (uint256[] memory amounts) {
received = amounts[amounts.length - 1];
totalBaseOut += received;
swapSucceeded = true;
} catch {}
if (swapSucceeded) {
buyBackStore.decrementAssetBalance(tokenIn, amountIn);
if (buyBackRewardAmount > 0) {
fundStore.transferOut(
tokenIn,
userAddress,
buyBackRewardAmount
);
emit RewardPaid(userAddress, tokenIn, buyBackRewardAmount);
buyBackStore.decrementAssetBalance(
tokenIn,
buyBackRewardAmount
);
}
emit TokensSwapped(userAddress, tokenIn, amountIn, received);
} else {
if (tokenIn == address(0)) {
IWrappedNative(WNative).withdraw(amountIn);
fundStore.transferIn{value: amountIn}(
address(0),
address(this),
amountIn
);
} else {
_approveTokenIfNeeded(
tokenIn,
address(fundStore),
amountIn
);
fundStore.transferIn(tokenIn, address(this), amountIn);
}
}
}
uint256 PinguBalance = IERC20(Pingu).balanceOf(address(this));
buyBackStore.incrementPinguBalance(PinguBalance);
fundStore.transferIn(address(Pingu), address(this), PinguBalance);
return totalBaseOut;
}
/// @notice Approve the token if needed
/// @param token The address of the token
/// @param spender The address of the spender
/// @param amount The amount of the token
/// @dev Internal function
function _approveTokenIfNeeded(
address token,
address spender,
uint256 amount
) internal {
IERC20 erc20 = IERC20(token);
uint256 currentAllowance = erc20.allowance(address(this), spender);
if (currentAllowance < amount) {
if (currentAllowance > 0) {
erc20.safeApprove(spender, 0);
}
erc20.safeApprove(spender, type(uint256).max);
}
}
/// @notice Compute the path for the swap
/// @param tokenIn The address of the token in
/// @return path The path for the swap
/// @dev Internal function
function _computePath(
address tokenIn
) internal view returns (address[] memory path) {
require(tokenIn != address(0), "Swapper: tokenIn is zero");
require(address(Pingu) != address(0), "Swapper: base not set");
require(address(factory) != address(0), "Swapper: factory not set");
if (tokenIn == address(Pingu)) {
return new address[](0);
}
if (_pairExists(tokenIn, address(Pingu))) {
path = new address[](2);
path[0] = tokenIn;
path[1] = address(Pingu);
return path;
}
uint256 hintsLen = routeHints.length;
address[] memory hops = new address[](hintsLen + 1);
uint256 count = 0;
if (
WNative != address(0) &&
WNative != tokenIn &&
WNative != address(Pingu)
) {
hops[count++] = WNative;
}
for (uint256 i = 0; i < hintsLen; i++) {
address h = routeHints[i];
if (h == address(0) || h == tokenIn || h == address(Pingu))
continue;
bool duplicate = false;
for (uint256 j = 0; j < count; j++) {
if (hops[j] == h) {
duplicate = true;
break;
}
}
if (!duplicate) {
hops[count++] = h;
}
}
for (uint256 i = 0; i < count; i++) {
address mid = hops[i];
if (_pairExists(tokenIn, mid) && _pairExists(mid, address(Pingu))) {
path = new address[](3);
path[0] = tokenIn;
path[1] = mid;
path[2] = address(Pingu);
return path;
}
}
for (uint256 i = 0; i < count; i++) {
address midA = hops[i];
if (!_pairExists(tokenIn, midA)) continue;
for (uint256 j = 0; j < count; j++) {
if (j == i) continue;
address midB = hops[j];
if (
_pairExists(midA, midB) && _pairExists(midB, address(Pingu))
) {
path = new address[](4);
path[0] = tokenIn;
path[1] = midA;
path[2] = midB;
path[3] = address(Pingu);
return path;
}
}
}
return new address[](0);
}
/// @notice Check if the pair exists
/// @param tokenA The address of the token A
/// @param tokenB The address of the token B
/// @return True if the pair exists, false otherwise
/// @dev Internal function
function _pairExists(
address tokenA,
address tokenB
) internal view returns (bool) {
address pair = factory.getPair(tokenA, tokenB);
return pair != address(0);
}
/// @notice Sync the router dependencies
/// @param newRouter The address of the new router
/// @dev Internal function
function _syncRouterDeps(address newRouter) internal {
address derivedFactory = IUniswapV2Router02(newRouter).factory();
require(
derivedFactory != address(0) && Address.isContract(derivedFactory),
"Swapper: invalid factory"
);
if (address(factory) != derivedFactory) {
emit FactoryUpdated(address(factory), derivedFactory);
factory = IUniswapV2Factory(derivedFactory);
}
address derivedWNative = IUniswapV2Router02(newRouter).WETH();
require(derivedWNative != address(0), "Swapper: invalid WNative");
if (WNative != derivedWNative) {
emit WNativeUpdated(WNative, derivedWNative);
WNative = derivedWNative;
}
}
/// @notice Withdraw the native token
/// @param amount The amount of the native token
/// @dev Only callable by governance
function withdrawNative(uint256 amount) external onlyGov {
require(
address(this).balance >= amount,
"Swapper: insufficient balance"
);
(bool ok, ) = payable(msg.sender).call{value: amount}("");
require(ok, "Swapper: native withdraw failed");
}
/// @notice Withdraw the ERC20 token
/// @param token The address of the token
/// @param amount The amount of the token
/// @dev Only callable by governance
function withdrawERC20(address token, uint256 amount) external onlyGov {
require(
IERC20(token).balanceOf(address(this)) >= amount,
"Swapper: insufficient balance"
);
IERC20(token).safeTransfer(msg.sender, amount);
}
receive() external payable {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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");
(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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.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 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'
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) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;
import "./Roles.sol";
/// @title BuyBackStore
/// @notice Persistent storage for BuyBack.sol
contract BuyBackStore is Roles {
// Constants
uint256 public constant BPS_DIVIDER = 10000;
uint256 public constant UNIT = 10 ** 18;
// Fee share for Buyback
uint256 public feeShare;
// Asset to balance
mapping(address => uint256) private assetsBalances;
uint256 public pinguBalance;
// BuyBack reward in bps
uint256 public buyBackReward;
// BuyBack paused state
bool public paused;
// @notice Initialize the BuyBackStore
/// @param rs The address of the RoleStore
function initialize(address rs) external initializer {
roleStore = RoleStore(rs);
_setGov(msg.sender);
pinguBalance = 0;
feeShare = 3500;
buyBackReward = 100;
paused = false;
}
/// @notice Set the fee share
/// @param _feeShare The fee share
function setFeeShare(uint256 _feeShare) external onlyGov {
require(_feeShare <= BPS_DIVIDER, "!feeShare");
feeShare = _feeShare;
}
/// @notice Set the buy back reward
/// @param _buyBackReward The buy back reward
function setBuyBackReward(uint256 _buyBackReward) external onlyGov {
require(_buyBackReward <= BPS_DIVIDER, "!reward");
buyBackReward = _buyBackReward;
}
/// @notice Set the paused state
/// @param _paused The paused state
function setPaused(bool _paused) external onlyGov {
paused = _paused;
}
/// @notice Increment the asset balance
/// @param asset The address of the asset
/// @param amount The amount of the asset
function incrementAssetBalance(
address asset,
uint256 amount
) external onlyContract {
assetsBalances[asset] += amount;
}
/// @notice Decrement the asset balance
/// @param asset The address of the asset
/// @param amount The amount of the asset
function decrementAssetBalance(
address asset,
uint256 amount
) external onlyContract {
assetsBalances[asset] = assetsBalances[asset] <= amount
? 0
: assetsBalances[asset] - amount;
}
/// @notice Reset the asset balance
/// @param asset The address of the asset
function resetAssetBalance(address asset) external onlyContract {
assetsBalances[asset] = 0;
}
/// @notice Increment the Pingu balance
/// @param amount The amount of the Pingu
function incrementPinguBalance(uint256 amount) external onlyContract {
pinguBalance += amount;
}
/// @notice Decrement the Pingu balance
/// @param amount The amount of the Pingu
function decrementPinguBalance(uint256 amount) external onlyContract {
pinguBalance = pinguBalance <= amount ? 0 : pinguBalance - amount;
}
/// @notice Reset the Pingu balance
function resetPinguBalance() external onlyContract {
pinguBalance = 0;
}
/// @notice Get the asset balance
/// @param asset The address of the asset
/// @return The balance of the asset
function getAssetBalance(address asset) external view returns (uint256) {
return assetsBalances[asset];
}
/// @notice Get the asset balances
/// @param assets The addresses of the assets
/// @return The balances of the assets array
function getAssetsBalances(
address[] memory assets
) external view returns (uint256[] memory) {
uint256 length = assets.length;
uint256[] memory balances = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
balances[i] = assetsBalances[assets[i]];
}
return balances;
}
/// @notice Get the Pingu balance
/// @return The balance of the Pingu
function getPinguBalance() external view returns (uint256) {
return pinguBalance;
}
/// @notice Get the fee share
/// @return The fee share
function getFeeShare() external view returns (uint256) {
return feeShare;
}
/// @notice Get the buy back reward
/// @return The buy back reward
function getBuyBackReward() external view returns (uint256) {
return buyBackReward;
}
/// @notice Get the paused state
/// @return The paused state
function isPaused() external view returns (bool) {
return paused;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./Roles.sol";
interface IWrappedNative {
function deposit() external payable;
function withdraw(uint256) external;
}
/// @title FundStore
/// @notice Storage of protocol funds
contract FundStore is Roles, ReentrancyGuard {
// Libraries
using SafeERC20 for IERC20;
using Address for address payable;
/// @notice WETH/Wrapped Native token address for fallback claims
address public weth;
/// @notice Pending payouts for recipients when direct transfer fails
/// @dev Mapping: asset => recipient => pending amount
mapping(address => mapping(address => uint256)) public pendingPayouts;
/// @notice Emitted when a transfer fails and amount is stored as pending
event TransferPending(address indexed asset, address indexed to, uint256 amount);
/// @notice Emitted when a recipient claims their pending payout
event TransferClaimed(address indexed asset, address indexed to, uint256 amount, bool asWeth);
function initialize(address rs) external initializer {
roleStore = RoleStore(rs);
_setGov(msg.sender);
}
/// @notice Sets the WETH address for fallback claims
/// @param _weth WETH contract address
function setWeth(address _weth) external onlyGov {
require(_weth != address(0), "Invalid WETH address");
weth = _weth;
}
/// @notice Transfers `amount` of `asset` in
/// @dev Only callable by other protocol contracts
/// @param asset Asset address, e.g. address(0) for ETH
/// @param from Address where asset is transferred from
function transferIn(
address asset,
address from,
uint256 amount
) external payable onlyContract {
if (asset == address(0)) {
require(amount > 0, "ETH:bad-amount");
require(msg.value == amount, "ETH:bad-amount");
return;
}
require(msg.value == 0, "ERC20:bad-value");
if (amount == 0) return;
IERC20(asset).safeTransferFrom(from, address(this), amount);
}
/// @notice Transfers `amount` of `asset` out
/// @dev Only callable by other protocol contracts
/// @dev For ETH: if transfer fails, amount is stored as pending payout (no revert)
/// @param asset Asset address, e.g. address(0) for ETH
/// @param to Address where asset is transferred to
function transferOut(
address asset,
address to,
uint256 amount
) external nonReentrant onlyContract {
if (amount == 0 || to == address(0)) return;
if (asset == address(0)) {
(bool success, ) = payable(to).call{value: amount}("");
if (!success) {
// Store as pending payout instead of reverting
pendingPayouts[asset][to] += amount;
emit TransferPending(asset, to, amount);
}
} else {
IERC20(asset).safeTransfer(to, amount);
}
}
/// @notice Allows recipients to claim their pending ETH payouts as native ETH
/// @dev Pull-based mechanism to avoid DoS from recipient contracts rejecting ETH
/// @dev If your contract cannot receive ETH, use claimAsWeth() instead
function claim() external nonReentrant {
uint256 amount = pendingPayouts[address(0)][msg.sender];
require(amount > 0, "Nothing to claim");
// Clear pending balance before transfer to prevent reentrancy
pendingPayouts[address(0)][msg.sender] = 0;
(bool success, ) = payable(msg.sender).call{value: amount}("");
require(success, "ETH transfer failed");
emit TransferClaimed(address(0), msg.sender, amount, false);
}
/// @notice Allows recipients to claim their pending ETH payouts as WETH
/// @dev Use this if your contract cannot receive native ETH
function claimAsWeth() external nonReentrant {
require(weth != address(0), "WETH not configured");
uint256 amount = pendingPayouts[address(0)][msg.sender];
require(amount > 0, "Nothing to claim");
// Clear pending balance before transfer to prevent reentrancy
pendingPayouts[address(0)][msg.sender] = 0;
// Wrap ETH to WETH
IWrappedNative(weth).deposit{value: amount}();
// Transfer WETH to recipient (ERC20 transfer cannot be rejected)
IERC20(weth).safeTransfer(msg.sender, amount);
emit TransferClaimed(address(0), msg.sender, amount, true);
}
/// @notice Returns the pending payout amount for a recipient
/// @param recipient Recipient address
/// @return Pending amount of ETH
function getPendingPayout(address recipient) external view returns (uint256) {
return pendingPayouts[address(0)][recipient];
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;
import {Governable} from "./Governable.sol";
/// @title DataStore
/// @notice General purpose storage contract
/// @dev Access is restricted to governance
contract DataStore is Governable {
// Key-value stores
mapping(bytes32 => uint256) public uintValues;
mapping(bytes32 => int256) public intValues;
mapping(bytes32 => address) public addressValues;
mapping(bytes32 => bytes32) public dataValues;
mapping(bytes32 => bool) public boolValues;
mapping(bytes32 => string) public stringValues;
function initialize() external initializer {
_setGov(msg.sender);
}
/// @param key The key for the record
/// @param value value to store
/// @param overwrite Overwrites existing value if set to true
function setUint(
string calldata key,
uint256 value,
bool overwrite
) external onlyGov returns (bool) {
bytes32 hash = getHash(key);
if (overwrite || uintValues[hash] == 0) {
uintValues[hash] = value;
return true;
}
return false;
}
/// @param key The key for the record
function getUint(string calldata key) external view returns (uint256) {
return uintValues[getHash(key)];
}
/// @param key The key for the record
/// @param value value to store
/// @param overwrite Overwrites existing value if set to true
function setInt(
string calldata key,
int256 value,
bool overwrite
) external onlyGov returns (bool) {
bytes32 hash = getHash(key);
if (overwrite || intValues[hash] == 0) {
intValues[hash] = value;
return true;
}
return false;
}
/// @param key The key for the record
function getInt(string calldata key) external view returns (int256) {
return intValues[getHash(key)];
}
/// @param key The key for the record
/// @param value address to store
/// @param overwrite Overwrites existing value if set to true
function setAddress(
string calldata key,
address value,
bool overwrite
) external onlyGov returns (bool) {
bytes32 hash = getHash(key);
if (overwrite || addressValues[hash] == address(0)) {
addressValues[hash] = value;
return true;
}
return false;
}
/// @param key The key for the record
function getAddress(string calldata key) external view returns (address) {
return addressValues[getHash(key)];
}
/// @param key The key for the record
/// @param value byte value to store
function setData(
string calldata key,
bytes32 value
) external onlyGov returns (bool) {
dataValues[getHash(key)] = value;
return true;
}
/// @param key The key for the record
function getData(string calldata key) external view returns (bytes32) {
return dataValues[getHash(key)];
}
/// @param key The key for the record
/// @param value value to store (true / false)
function setBool(
string calldata key,
bool value
) external onlyGov returns (bool) {
boolValues[getHash(key)] = value;
return true;
}
/// @param key The key for the record
function getBool(string calldata key) external view returns (bool) {
return boolValues[getHash(key)];
}
/// @param key The key for the record
/// @param value string to store
function setString(
string calldata key,
string calldata value
) external onlyGov returns (bool) {
stringValues[getHash(key)] = value;
return true;
}
/// @param key The key for the record
function getString(
string calldata key
) external view returns (string memory) {
return stringValues[getHash(key)];
}
/// @param key string to hash
function getHash(string memory key) public pure returns (bytes32) {
return keccak256(abi.encodePacked(key));
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;
import "./Governable.sol";
import "./RoleStore.sol";
/// @title Roles
/// @notice Role-based access control mechanism via onlyContract modifier
abstract contract Roles is Governable {
bytes32 internal constant CONTRACT_ROLE = keccak256("CONTRACT");
RoleStore public roleStore;
/// @dev Reverts if caller address has not the contract role
modifier onlyContract() {
require(roleStore.hasRole(msg.sender, CONTRACT_ROLE), "!contract-role");
_;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
/// @title Governable
/// @notice Basic access control mechanism, gov has access to certain functions
abstract contract Governable is Initializable {
address public gov;
event SetGov(address prevGov, address nextGov);
/// @dev Reverts if called by any account other than gov
modifier onlyGov() {
require(msg.sender == gov, "!gov");
_;
}
/// @notice Sets a new governance address
/// @dev Only callable by governance
function setGov(address _gov) external onlyGov {
_setGov(_gov);
}
/// @notice Sets a new governance address
/// @dev Internal function without access restriction
function _setGov(address _gov) internal {
require(_gov != address(0), "!zero-gov");
address prevGov = gov;
gov = _gov;
emit SetGov(prevGov, _gov);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;
import "./EnumerableSet.sol";
import "./Governable.sol";
/**
* @title RoleStore
* @notice Role-based access control mechanism. Governance can grant and
* revoke roles dynamically via {grantRole} and {revokeRole}
*/
contract RoleStore is Governable {
// Libraries
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableSet for EnumerableSet.Bytes32Set;
event RoleGranted(
bytes32 indexed role,
address indexed account,
address indexed sender
);
event RoleRevoked(
bytes32 indexed role,
address indexed account,
address indexed sender
);
// Set of roles
EnumerableSet.Bytes32Set internal roles;
// Role -> address
mapping(bytes32 => EnumerableSet.AddressSet) internal roleMembers;
function initialize() external initializer {
_setGov(msg.sender);
}
/// @notice Grants `role` to `account`
/// @dev Only callable by governance
function grantRole(address account, bytes32 role) external onlyGov {
// add role if not already present
if (!roles.contains(role)) roles.add(role);
require(roleMembers[role].add(account));
emit RoleGranted(role, account, msg.sender);
}
/// @notice Revokes `role` from `account`
/// @dev Only callable by governance
function revokeRole(address account, bytes32 role) external onlyGov {
require(roleMembers[role].remove(account));
emit RoleRevoked(role, account, msg.sender);
// Remove role if it has no longer any members
if (roleMembers[role].length() == 0) {
roles.remove(role);
}
}
/// @notice Returns `true` if `account` has been granted `role`
function hasRole(
address account,
bytes32 role
) external view returns (bool) {
return roleMembers[role].contains(account);
}
/// @notice Returns number of roles
function getRoleCount() external view returns (uint256) {
return roles.length();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/Address.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Internal function that returns the initialized version. Returns `_initialized`
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Internal function that returns the initialized version. Returns `_initializing`
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity 0.8.17;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(
Set storage set,
bytes32 value
) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(
Set storage set,
uint256 index
) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(
Bytes32Set storage set,
bytes32 value
) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(
Bytes32Set storage set,
bytes32 value
) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(
Bytes32Set storage set,
bytes32 value
) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(
Bytes32Set storage set,
uint256 index
) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(
Bytes32Set storage set
) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(
AddressSet storage set,
address value
) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(
AddressSet storage set,
address value
) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(
AddressSet storage set,
address value
) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(
AddressSet storage set,
uint256 index
) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(
AddressSet storage set
) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(
UintSet storage set,
uint256 value
) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(
UintSet storage set,
uint256 value
) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(
UintSet storage set,
uint256 index
) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(
UintSet storage set
) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}{
"remappings": [
"@openzeppelin/=lib/openzeppelin-contracts/",
"chainlink/=node_modules/@chainlink/",
"pyth-sdk-solidity/=node_modules/@pythnetwork/pyth-sdk-solidity/",
"@uniswap/v2-periphery/=node_modules/@uniswap/v2-periphery/",
"@uniswap/v2-core/=node_modules/@uniswap/v2-core/",
"ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousFactory","type":"address"},{"indexed":true,"internalType":"address","name":"newFactory","type":"address"}],"name":"FactoryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newMaxSlippageBps","type":"uint256"}],"name":"MaxSlippageUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"minAmount","type":"uint256"}],"name":"MinAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousRouter","type":"address"},{"indexed":true,"internalType":"address","name":"newRouter","type":"address"}],"name":"RouterUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"prevGov","type":"address"},{"indexed":false,"internalType":"address","name":"nextGov","type":"address"}],"name":"SetGov","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"TokensSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousWNative","type":"address"},{"indexed":true,"internalType":"address","name":"newWNative","type":"address"}],"name":"WNativeUpdated","type":"event"},{"inputs":[],"name":"BPS_DIVIDER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DS","outputs":[{"internalType":"contract DataStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"Pingu","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WNative","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyBackStore","outputs":[{"internalType":"contract BuyBackStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract IUniswapV2Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundStore","outputs":[{"internalType":"contract FundStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"ds","type":"address"},{"internalType":"address","name":"rs","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"link","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSlippageBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"roleStore","outputs":[{"internalType":"contract RoleStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"routeHints","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxSlippageBps","type":"uint256"}],"name":"setMaxSlippageBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setMinAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"setMinAmounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"setRouteHints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRouter","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"swapTokensForBaseAuto","outputs":[{"internalType":"uint256","name":"totalBaseOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
6080806040523461001657612786908161001c8239f35b600080fdfe608080604052600436101561001d575b50361561001b57600080fd5b005b60003560e01c908163032e73e31461180e57508063077d17f8146117e557806312d43a51146117b85780631c4695f41461159957806325fc1b3d146114ce5780634242bac0146114a55780634a4a7b041461147c5780634d0a32db146114425780636dff469b146113e75780637c4283bc146113ca57806384276d81146113365780638b616db21461130d5780639d8e2177146112ea578063a1db9782146111ff578063c0c53b8b14610fd7578063c0d7865514610f48578063c45a015514610f1f578063c4aa739514610f01578063cfad57a214610ec8578063d5708d5a14610e54578063f3ec43c714610e2b578063f5bdb46914610ced578063f5ce24b014610b83578063f887ea4014610b5a5763fdd35bd31461013d573861000f565b34610338576040366003190112610338576004356001600160401b0381116103385761016d9036906004016118ab565b90610176611848565b60015460405163ac4ab3fb60e01b81523360048201527fa66b7a3e6b19d24ccb6f717fc232a1bb0278a7f83f8e2211835fc4ed0fe69f19602482015290602090829060449082906001600160a01b03165afa90811561032c57600091610b2b575b5015610af5576002600b5414610ab0576002600b556008546040516336d2109960e21b81526000949091602090839060049082906001600160a01b03165afa91821561032c57600092610a7c575b5060005b818110610380576002546040516370a0823160e01b8152306004820152908790602090839060249082906001600160a01b03165afa91821561032c5760009261034c575b506008546001600160a01b0316803b15610338576000809160246040518094819363728d710560e11b83528860048401525af1801561032c5761033d575b506007546002546001600160a01b0391821693911690833b156103385760405163e4652f4960e01b81526001600160a01b039290921660048301523060248301526044820152916000908390606490829084905af191821561032c5760209261031d575b506001600b55604051908152f35b61032690611a5e565b8261030f565b6040513d6000823e3d90fd5b600080fd5b61034690611a5e565b826102ab565b9091506020813d602011610378575b8161036860209383611a8c565b810103126103385751908261026d565b3d915061035b565b61039361038e828488611adb565b611aeb565b906001600160a01b038216610a76576003546001600160a01b0316915b6001600160a01b0383166000908152600960205260409020548015610a3657600854604051635373433f60e01b81526001600160a01b0380851660048301529093929160209185916024918391165afa92831561032c57600093610a42575b508210610a365761041f8461200b565b93845115610a29576127106104348489611aff565b0494838681031161089757858414610a1b57600091600c5480610938575b506007546001600160a01b0316803b156103385760405163078d3b7960e01b81526001600160a01b03861660048201523060248201528887036044820152906000908290606490829084905af1801561032c57610929575b506001600160a01b038416156108d2575b6004546104d591888703916001600160a01b031690611c38565b6004546000928392916001600160a01b0316904261012c8101106108975760009189838961052c604051978896879586946338ed173960e01b8652036004850152602484015260a0604484015260a4830190611bba565b30606483015261012c4201608483015203925af1600091816108ad575b50610862575b501561071d576008546001600160a01b0316803b156103385760405163836da2b760e01b81526001600160a01b03841660048201528685036024820152906000908290604490829084905af1801561032c5761070e575b50846105fd575b6040805195909303855260208501526105f8936001600160a01b0391821692918816917f25f1d03755df23c30e25db2dbd3891e31ce084bdfbfc46f9fe5e446ee5f9b2d491a3611acc565b610229565b6007546001600160a01b0316803b156103385760405163078d3b7960e01b81526001600160a01b0384811660048301528a16602482015260448101879052906000908290606490829084905af1801561032c576106ff575b506040518581526001600160a01b0383811691908a16907f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e90602090a36008546001600160a01b031694853b156103385760405163836da2b760e01b81526001600160a01b038416600482015260248101829052956000908790604490829084905af195861561032c576105f8966106f0575b5094506105ad565b6106f990611a5e565b386106e8565b61070890611a5e565b38610655565b61071790611a5e565b386105a6565b506001600160a01b0381166107e457506003546001600160a01b0316803b156103385760008091602460405180948193632e1a7d4d60e01b835289880360048401525af1801561032c576107d5575b506007546001600160a01b031692833b15610338576064600092604051958693849263e4652f4960e01b8452866004850152306024850152818103604485015203905af191821561032c576105f8926107c6575b50611acc565b6107cf90611a5e565b386107c0565b6107de90611a5e565b3861076c565b6007546107fe90858403906001600160a01b031683611c38565b6007546001600160a01b0316803b156103385760405163e4652f4960e01b81526001600160a01b03929092166004830152306024830152939091036044820152916000908390606490829084905af191821561032c576105f8926107c65750611acc565b9150508051908160001981011161089757610881916000190190611c24565b519889810181116108975789019860013861054f565b634e487b7160e01b600052601160045260246000fd5b6108cb9192503d806000833e6108c38183611a8c565b810190611b41565b9038610549565b6003546001600160a01b031690813b1561033857600060049260405193848092630d0e30db60e41b82528c8b03905af191821561032c576104d59261091a575b5090506104bb565b61092390611a5e565b38610912565b61093290611a5e565b386104aa565b90925060018060a01b03600454166000604051809263d06ca61f60e01b82528a890360048301526040602483015281806109756044820189611bba565b03915afa600091816109fe575b50610997575050505050506105f89150611acc565b80516000198101908111610897576109ae91611c24565b519081156109ee576127100390612710821161089757612710916109d191611aff565b049182156109df5738610452565b50505050506105f89150611acc565b5050505050506105f89150611acc565b610a149192503d806000833e6108c38183611a8c565b9038610982565b505050506105f89150611acc565b5050506105f89150611acc565b50506105f89150611acc565b9092506020813d602011610a6e575b81610a5e60209383611a8c565b810103126103385751913861040f565b3d9150610a51565b816103b0565b9091506020813d602011610aa8575b81610a9860209383611a8c565b8101031261033857519038610225565b3d9150610a8b565b60405162461bcd60e51b815260206004820152601760248201527f537761707065723a207265656e7472616e742063616c6c0000000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d21636f6e74726163742d726f6c6560901b6044820152606490fd5b610b4d915060203d602011610b53575b610b458183611a8c565b810190611b12565b386101d7565b503d610b3b565b34610338576000366003190112610338576004546040516001600160a01b039091168152602090f35b3461033857602080600319360112610338576004356001600160401b03811161033857610bb49036906004016118ab565b60018060a09493941b0390610bd18260005460101c1633146118db565b600a9384546000865580610caa575b5060005b828110610bed57005b83610bfc61038e838686611adb565b1615610c7057610c1061038e828585611adb565b9086549168010000000000000000831015610c5a5785610c38846001610c5596018b5561185e565b909283549160031b83811b93849216901b16911916179055611acc565b610be4565b634e487b7160e01b600052604160045260246000fd5b60405162461bcd60e51b815260048101869052601260248201527114ddd85c1c195c8e881e995c9bc81a1a5b9d60721b6044820152606490fd5b856000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8908101905b818110610ce15750610be0565b60008155600101610cd4565b34610338576040366003190112610338576001600160401b0360043581811161033857610d1e9036906004016118ab565b9160243590811161033857610d379036906004016118ab565b9260018060a01b0392610d528460005460101c1633146118db565b848203610de65760005b828110610d6557005b80610d74610de1928887611adb565b3586610d8461038e848888611adb565b16600052602090600982526040600020557f661459273999943a19efbd948eb50b734e8c71b010cc26221bd1efeffd1dccb5610dc461038e848888611adb565b9188610dd1858c8b611adb565b35936040519485521692a2611acc565b610d5c565b60405162461bcd60e51b815260206004820152601e60248201527f537761707065723a206172726179206c656e677468206d69736d6174636800006044820152606490fd5b34610338576000366003190112610338576003546040516001600160a01b039091168152602090f35b3461033857604036600319011261033857610e6d611832565b7f661459273999943a19efbd948eb50b734e8c71b010cc26221bd1efeffd1dccb560206024359260018060a01b0390610eae8260005460101c1633146118db565b1692836000526009825280604060002055604051908152a2005b346103385760203660031901126103385761001b610ee4611832565b610efc60018060a01b0360005460101c1633146118db565b61190d565b34610338576000366003190112610338576020600c54604051908152f35b34610338576000366003190112610338576005546040516001600160a01b039091168152602090f35b346103385760203660031901126103385761001b610f64611832565b60018060a01b03610f7d8160005460101c1633146118db565b80821690610f8c8215156119bb565b610f98833b1515611a07565b816004549182167f02dc5c233404867c793b749c6d644beb2277536d18a7e7974d3f238e4c6f1684600080a36001600160a01b0319161760045561250c565b3461033857606036600319011261033857610ff0611832565b610ff8611848565b6001600160a01b0360443581811693919290849003610338576000549360ff8560081c1615948580966111f2575b80156111db575b1561117f5760ff1981166001176000558561116d575b50838316906110538215156119bb565b61105f843b1515611a07565b846bffffffffffffffffffffffff60a01b931683600654161760065582600154161760015561108d3361190d565b6001600b558160045416176004558260065416926020604051809563bf40fac160e01b825281806110db6004820160609060208152600560208201526450494e475560d81b60408201520190565b03915afa801561032c576111019460009161113f575b501690600254161760025561250c565b61110757005b61ff0019600054166000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1005b611160915060203d8111611166575b6111588183611a8c565b810190611aad565b866110f1565b503d61114e565b61ffff19166101011760005585611043565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b15801561102d5750600160ff82161461102d565b50600160ff821610611026565b3461033857604036600319011261033857611218611832565b6024359060018060a01b03906112368260005460101c1633146118db565b16906040516370a0823160e01b8152306004820152602081602481865afa90811561032c576000916112b5575b61001b6112a2856112b08661127a81881015612704565b60405163a9059cbb60e01b602082015233602482015260448101919091529283906064820190565b03601f198101845283611a8c565b611e0d565b9290506020833d82116112e2575b816112d060209383611a8c565b810103126103385791516112b0611263565b3d91506112c3565b34610338576000366003190112610338576020604051670de0b6b3a76400008152f35b34610338576000366003190112610338576002546040516001600160a01b039091168152602090f35b3461033857602036600319011261033857600080808060043561136660018060a01b03835460101c1633146118db565b61137281471015612704565b335af161137d611ef8565b501561138557005b60405162461bcd60e51b815260206004820152601f60248201527f537761707065723a206e6174697665207769746864726177206661696c6564006044820152606490fd5b346103385760003660031901126103385760206040516127108152f35b3461033857602036600319011261033857600435600a5481101561033857600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a801546040516001600160a01b039091168152602090f35b34610338576020366003190112610338576001600160a01b03611463611832565b1660005260096020526020604060002054604051908152f35b34610338576000366003190112610338576001546040516001600160a01b039091168152602090f35b34610338576000366003190112610338576006546040516001600160a01b039091168152602090f35b34610338576020366003190112610338576004356114fa60018060a01b0360005460101c1633146118db565b612710811161152e5780600c557f9c922f6d0c990b250e9dd0a427a5c8da7f44b960f697fecb31cbbd8ba79ec8c2600080a2005b60405162461bcd60e51b815260206004820152603860248201527f537761707065723a206d617820736c697070616765206d757374206265206c6560448201527f7373207468616e206f7220657175616c20746f203130302500000000000000006064820152608490fd5b346103385760003660031901126103385760018060a01b036115c38160005460101c1633146118db565b80600654166040519163bf40fac160e01b90818452602093846004820152600960248201526846756e6453746f726560b81b60448201528481606481875afa801561032c57829160009161179b575b5016926bffffffffffffffffffffffff60a01b928484600754161760075560405190808252866004830152600c60248301526b4275794261636b53746f726560a01b60448301528682606481865afa91821561032c578792859160009161177e575b5016856008541617600855604051928391825281806116b06004820160609060208152600560208201526450494e475560d81b60408201520190565b03915afa90811561032c57600091611761575b506002805491909216921682179055604051636eb1769f60e11b81523060048201526001600160a01b03831660248201528381604481855afa93841561032c57600094611731575b5050600019831061171857005b61001b9215611d04575b61172c8282611cc9565b611d04565b9080929450813d831161175a575b6117498183611a8c565b81010312610338575191838061170b565b503d61173f565b6117789150853d8711611166576111588183611a8c565b856116c3565b6117959150843d8611611166576111588183611a8c565b89611674565b6117b29150863d8811611166576111588183611a8c565b86611612565b346103385760003660031901126103385760005460405160109190911c6001600160a01b03168152602090f35b34610338576000366003190112610338576007546040516001600160a01b039091168152602090f35b34610338576000366003190112610338576008546001600160a01b03168152602090f35b600435906001600160a01b038216820361033857565b602435906001600160a01b038216820361033857565b600a5481101561189557600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80190600090565b634e487b7160e01b600052603260045260246000fd5b9181601f84011215610338578235916001600160401b038311610338576020808501948460051b01011161033857565b156118e257565b606460405162461bcd60e51b815260206004820152600460248201526310b3b7bb60e11b6044820152fd5b6001600160a01b038181161561198a576000805462010000600160b01b03198116601085811b62010000600160b01b031691909117909255604080516001600160a01b039290931c939093168116825290921660208301527f53351836099c03ffc3b1727d8abd4b0222afa87d4ed76ae3102d51369ef7f78591a1565b60405162461bcd60e51b815260206004820152600960248201526810bd32b93796b3b7bb60b91b6044820152606490fd5b156119c257565b60405162461bcd60e51b815260206004820152601760248201527f537761707065723a20726f75746572206973207a65726f0000000000000000006044820152606490fd5b15611a0e57565b60405162461bcd60e51b815260206004820152602260248201527f537761707065723a20726f75746572206d757374206265206120636f6e74726160448201526118dd60f21b6064820152608490fd5b6001600160401b038111610c5a57604052565b608081019081106001600160401b03821117610c5a57604052565b90601f801991011681019081106001600160401b03821117610c5a57604052565b9081602091031261033857516001600160a01b03811681036103385790565b60001981146108975760010190565b91908110156118955760051b0190565b356001600160a01b03811681036103385790565b8181029291811591840414171561089757565b90816020910312610338575180151581036103385790565b6001600160401b038111610c5a5760051b60200190565b6020908181840312610338578051906001600160401b03821161033857019180601f84011215610338578251611b7681611b2a565b93611b846040519586611a8c565b818552838086019260051b820101928311610338578301905b828210611bab575050505090565b81518152908301908301611b9d565b90815180825260208080930193019160005b828110611bda575050505090565b83516001600160a01b031685529381019392810192600101611bcc565b8051156118955760200190565b8051600110156118955760400190565b8051600210156118955760600190565b80518210156118955760209160051b010190565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529093911690602084604481855afa93841561032c57600094611c93575b508310611c8457505050565b611c919261172257611d04565b565b90936020823d8211611cc1575b81611cad60209383611a8c565b81010312611cbe5750519238611c78565b80fd5b3d9150611ca0565b60405163095ea7b360e01b60208201526001600160a01b03909216602483015260006044808401919091528252611c9191906112b082611a71565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529293926020929183816044818686165afa90811561032c57600091611de0575b50611d7c57611c9193946040519363095ea7b360e01b908501521660248301526000196044830152604482526112b082611a71565b60405162461bcd60e51b815260048101849052603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608490fd5b908482813d8311611e06575b611df68183611a8c565b81010312611cbe57505138611d47565b503d611dec565b60408051908101916001600160a01b03166001600160401b03831182841017610c5a57611e7c926040526000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af1611e76611ef8565b91611f37565b80519081611e8957505050565b8280611e99938301019101611b12565b15611ea15750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b3d15611f32573d906001600160401b038211610c5a5760405191611f26601f8201601f191660200184611a8c565b82523d6000602084013e565b606090565b91929015611f995750815115611f4b575090565b3b15611f545790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015611fac5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510611ff2575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350611fcf565b6001600160a01b039080821690811561245a578260025416801561241d578360055416156123d8578083146123ac57612044818361249f565b61236c57600a5490600193848301948584116108975761206386611b2a565b9460409661207388519788611a8c565b808752612082601f1991611b2a565b0197602098368a8901376000956003938285541680151580612362575b80612358575b612344575b5060005b8281106122935750505060005b868110612203575060005b8681106120fa5750505050505050508051918201908282106001600160401b03831117610c5a575260008152600036813790565b81612105828a611c24565b5116612111818561249f565b156121f95760005b88811061213057505061212b90611acc565b6120c6565b8281146121f05783612142828c611c24565b511661214e818461249f565b806121e0575b612167575061216290611acc565b612119565b9698505093959899975050505086519660a08801908882106001600160401b03831117610c5a57526004938488526080809636908a01376121a788611bf7565b526121b187611c04565b526121bb86611c14565b52845111156121cb575082015290565b603290634e487b7160e01b6000525260246000fd5b506121eb898261249f565b612154565b61216290611acc565b5061212b90611acc565b8161220e828a611c24565b511661221a818561249f565b80612283575b612233575061222e90611acc565b6120bb565b9750505050959092508491945195608087018781106001600160401b03821117610c5a57606093528652369086013761226b84611bf7565b5261227583611c04565b5261227f82611c14565b5290565b5061228e878261249f565b612220565b8361229d8261185e565b905490881b1c168015801561233b575b8015612332575b612328576000805b868d8d83106122f9575b505050906122da9291156122df5750611acc565b6120ae565b6122f26122eb8c611acc565b9b8d611c24565b52386107c0565b90612305838693611c24565b51161461231a5761231590611acc565b6122bc565b508390506122da868d6122c6565b506122da90611acc565b508881146122b4565b508781146122ad565b975080976123518a611bf7565b52386120aa565b50878114156120a5565b508681141561209f565b9192505060405191606083018381106001600160401b03821117610c5a576040526002835260403660208501376123a283611bf7565b5261227f82611c04565b50505050604051602081018181106001600160401b03821117610c5a5760405260008152600036813790565b60405162461bcd60e51b815260206004820152601860248201527f537761707065723a20666163746f7279206e6f742073657400000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601560248201527414ddd85c1c195c8e8818985cd9481b9bdd081cd95d605a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601860248201527f537761707065723a20746f6b656e496e206973207a65726f00000000000000006044820152606490fd5b60055460405163e6a4390560e01b81526001600160a01b03928316600482015292821660248401529091906020908290604490829086165afa90811561032c576000916124ee575b5016151590565b612506915060203d8111611166576111588183611a8c565b386124e7565b6040805163c45a015560e01b815290916001600160a01b03916020918316908281600481855afa9081156126f9576000916126dc575b508381169081151590816126d1575b501561268d576004918391600554868116828103612650575b5050508551928380926315ab88c960e31b82525afa90811561264557908391600091612628575b50169283156125e55750506003549081168281036125ae57505050565b82907f9a840e37cdc9259cd902f02ce82539dcac055dd28cabd649612afaba13a89206600080a36001600160a01b03191617600355565b60649250519062461bcd60e51b82526004820152601860248201527f537761707065723a20696e76616c696420574e617469766500000000000000006044820152fd5b61263f9150833d8511611166576111588183611a8c565b38612591565b84513d6000823e3d90fd5b82907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb555600080a36001600160a01b0319161760055538808061256a565b845162461bcd60e51b815260048101849052601860248201527f537761707065723a20696e76616c696420666163746f727900000000000000006044820152606490fd5b90503b151538612551565b6126f39150833d8511611166576111588183611a8c565b38612542565b85513d6000823e3d90fd5b1561270b57565b60405162461bcd60e51b815260206004820152601d60248201527f537761707065723a20696e73756666696369656e742062616c616e63650000006044820152606490fdfea26469706673582212209a33b7e1dfed5079f2aed49215c7af83fdf43f95e1e9871b6841b3a4df74849464736f6c63430008110033
Deployed Bytecode
0x608080604052600436101561001d575b50361561001b57600080fd5b005b60003560e01c908163032e73e31461180e57508063077d17f8146117e557806312d43a51146117b85780631c4695f41461159957806325fc1b3d146114ce5780634242bac0146114a55780634a4a7b041461147c5780634d0a32db146114425780636dff469b146113e75780637c4283bc146113ca57806384276d81146113365780638b616db21461130d5780639d8e2177146112ea578063a1db9782146111ff578063c0c53b8b14610fd7578063c0d7865514610f48578063c45a015514610f1f578063c4aa739514610f01578063cfad57a214610ec8578063d5708d5a14610e54578063f3ec43c714610e2b578063f5bdb46914610ced578063f5ce24b014610b83578063f887ea4014610b5a5763fdd35bd31461013d573861000f565b34610338576040366003190112610338576004356001600160401b0381116103385761016d9036906004016118ab565b90610176611848565b60015460405163ac4ab3fb60e01b81523360048201527fa66b7a3e6b19d24ccb6f717fc232a1bb0278a7f83f8e2211835fc4ed0fe69f19602482015290602090829060449082906001600160a01b03165afa90811561032c57600091610b2b575b5015610af5576002600b5414610ab0576002600b556008546040516336d2109960e21b81526000949091602090839060049082906001600160a01b03165afa91821561032c57600092610a7c575b5060005b818110610380576002546040516370a0823160e01b8152306004820152908790602090839060249082906001600160a01b03165afa91821561032c5760009261034c575b506008546001600160a01b0316803b15610338576000809160246040518094819363728d710560e11b83528860048401525af1801561032c5761033d575b506007546002546001600160a01b0391821693911690833b156103385760405163e4652f4960e01b81526001600160a01b039290921660048301523060248301526044820152916000908390606490829084905af191821561032c5760209261031d575b506001600b55604051908152f35b61032690611a5e565b8261030f565b6040513d6000823e3d90fd5b600080fd5b61034690611a5e565b826102ab565b9091506020813d602011610378575b8161036860209383611a8c565b810103126103385751908261026d565b3d915061035b565b61039361038e828488611adb565b611aeb565b906001600160a01b038216610a76576003546001600160a01b0316915b6001600160a01b0383166000908152600960205260409020548015610a3657600854604051635373433f60e01b81526001600160a01b0380851660048301529093929160209185916024918391165afa92831561032c57600093610a42575b508210610a365761041f8461200b565b93845115610a29576127106104348489611aff565b0494838681031161089757858414610a1b57600091600c5480610938575b506007546001600160a01b0316803b156103385760405163078d3b7960e01b81526001600160a01b03861660048201523060248201528887036044820152906000908290606490829084905af1801561032c57610929575b506001600160a01b038416156108d2575b6004546104d591888703916001600160a01b031690611c38565b6004546000928392916001600160a01b0316904261012c8101106108975760009189838961052c604051978896879586946338ed173960e01b8652036004850152602484015260a0604484015260a4830190611bba565b30606483015261012c4201608483015203925af1600091816108ad575b50610862575b501561071d576008546001600160a01b0316803b156103385760405163836da2b760e01b81526001600160a01b03841660048201528685036024820152906000908290604490829084905af1801561032c5761070e575b50846105fd575b6040805195909303855260208501526105f8936001600160a01b0391821692918816917f25f1d03755df23c30e25db2dbd3891e31ce084bdfbfc46f9fe5e446ee5f9b2d491a3611acc565b610229565b6007546001600160a01b0316803b156103385760405163078d3b7960e01b81526001600160a01b0384811660048301528a16602482015260448101879052906000908290606490829084905af1801561032c576106ff575b506040518581526001600160a01b0383811691908a16907f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e90602090a36008546001600160a01b031694853b156103385760405163836da2b760e01b81526001600160a01b038416600482015260248101829052956000908790604490829084905af195861561032c576105f8966106f0575b5094506105ad565b6106f990611a5e565b386106e8565b61070890611a5e565b38610655565b61071790611a5e565b386105a6565b506001600160a01b0381166107e457506003546001600160a01b0316803b156103385760008091602460405180948193632e1a7d4d60e01b835289880360048401525af1801561032c576107d5575b506007546001600160a01b031692833b15610338576064600092604051958693849263e4652f4960e01b8452866004850152306024850152818103604485015203905af191821561032c576105f8926107c6575b50611acc565b6107cf90611a5e565b386107c0565b6107de90611a5e565b3861076c565b6007546107fe90858403906001600160a01b031683611c38565b6007546001600160a01b0316803b156103385760405163e4652f4960e01b81526001600160a01b03929092166004830152306024830152939091036044820152916000908390606490829084905af191821561032c576105f8926107c65750611acc565b9150508051908160001981011161089757610881916000190190611c24565b519889810181116108975789019860013861054f565b634e487b7160e01b600052601160045260246000fd5b6108cb9192503d806000833e6108c38183611a8c565b810190611b41565b9038610549565b6003546001600160a01b031690813b1561033857600060049260405193848092630d0e30db60e41b82528c8b03905af191821561032c576104d59261091a575b5090506104bb565b61092390611a5e565b38610912565b61093290611a5e565b386104aa565b90925060018060a01b03600454166000604051809263d06ca61f60e01b82528a890360048301526040602483015281806109756044820189611bba565b03915afa600091816109fe575b50610997575050505050506105f89150611acc565b80516000198101908111610897576109ae91611c24565b519081156109ee576127100390612710821161089757612710916109d191611aff565b049182156109df5738610452565b50505050506105f89150611acc565b5050505050506105f89150611acc565b610a149192503d806000833e6108c38183611a8c565b9038610982565b505050506105f89150611acc565b5050506105f89150611acc565b50506105f89150611acc565b9092506020813d602011610a6e575b81610a5e60209383611a8c565b810103126103385751913861040f565b3d9150610a51565b816103b0565b9091506020813d602011610aa8575b81610a9860209383611a8c565b8101031261033857519038610225565b3d9150610a8b565b60405162461bcd60e51b815260206004820152601760248201527f537761707065723a207265656e7472616e742063616c6c0000000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d21636f6e74726163742d726f6c6560901b6044820152606490fd5b610b4d915060203d602011610b53575b610b458183611a8c565b810190611b12565b386101d7565b503d610b3b565b34610338576000366003190112610338576004546040516001600160a01b039091168152602090f35b3461033857602080600319360112610338576004356001600160401b03811161033857610bb49036906004016118ab565b60018060a09493941b0390610bd18260005460101c1633146118db565b600a9384546000865580610caa575b5060005b828110610bed57005b83610bfc61038e838686611adb565b1615610c7057610c1061038e828585611adb565b9086549168010000000000000000831015610c5a5785610c38846001610c5596018b5561185e565b909283549160031b83811b93849216901b16911916179055611acc565b610be4565b634e487b7160e01b600052604160045260246000fd5b60405162461bcd60e51b815260048101869052601260248201527114ddd85c1c195c8e881e995c9bc81a1a5b9d60721b6044820152606490fd5b856000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8908101905b818110610ce15750610be0565b60008155600101610cd4565b34610338576040366003190112610338576001600160401b0360043581811161033857610d1e9036906004016118ab565b9160243590811161033857610d379036906004016118ab565b9260018060a01b0392610d528460005460101c1633146118db565b848203610de65760005b828110610d6557005b80610d74610de1928887611adb565b3586610d8461038e848888611adb565b16600052602090600982526040600020557f661459273999943a19efbd948eb50b734e8c71b010cc26221bd1efeffd1dccb5610dc461038e848888611adb565b9188610dd1858c8b611adb565b35936040519485521692a2611acc565b610d5c565b60405162461bcd60e51b815260206004820152601e60248201527f537761707065723a206172726179206c656e677468206d69736d6174636800006044820152606490fd5b34610338576000366003190112610338576003546040516001600160a01b039091168152602090f35b3461033857604036600319011261033857610e6d611832565b7f661459273999943a19efbd948eb50b734e8c71b010cc26221bd1efeffd1dccb560206024359260018060a01b0390610eae8260005460101c1633146118db565b1692836000526009825280604060002055604051908152a2005b346103385760203660031901126103385761001b610ee4611832565b610efc60018060a01b0360005460101c1633146118db565b61190d565b34610338576000366003190112610338576020600c54604051908152f35b34610338576000366003190112610338576005546040516001600160a01b039091168152602090f35b346103385760203660031901126103385761001b610f64611832565b60018060a01b03610f7d8160005460101c1633146118db565b80821690610f8c8215156119bb565b610f98833b1515611a07565b816004549182167f02dc5c233404867c793b749c6d644beb2277536d18a7e7974d3f238e4c6f1684600080a36001600160a01b0319161760045561250c565b3461033857606036600319011261033857610ff0611832565b610ff8611848565b6001600160a01b0360443581811693919290849003610338576000549360ff8560081c1615948580966111f2575b80156111db575b1561117f5760ff1981166001176000558561116d575b50838316906110538215156119bb565b61105f843b1515611a07565b846bffffffffffffffffffffffff60a01b931683600654161760065582600154161760015561108d3361190d565b6001600b558160045416176004558260065416926020604051809563bf40fac160e01b825281806110db6004820160609060208152600560208201526450494e475560d81b60408201520190565b03915afa801561032c576111019460009161113f575b501690600254161760025561250c565b61110757005b61ff0019600054166000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1005b611160915060203d8111611166575b6111588183611a8c565b810190611aad565b866110f1565b503d61114e565b61ffff19166101011760005585611043565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b15801561102d5750600160ff82161461102d565b50600160ff821610611026565b3461033857604036600319011261033857611218611832565b6024359060018060a01b03906112368260005460101c1633146118db565b16906040516370a0823160e01b8152306004820152602081602481865afa90811561032c576000916112b5575b61001b6112a2856112b08661127a81881015612704565b60405163a9059cbb60e01b602082015233602482015260448101919091529283906064820190565b03601f198101845283611a8c565b611e0d565b9290506020833d82116112e2575b816112d060209383611a8c565b810103126103385791516112b0611263565b3d91506112c3565b34610338576000366003190112610338576020604051670de0b6b3a76400008152f35b34610338576000366003190112610338576002546040516001600160a01b039091168152602090f35b3461033857602036600319011261033857600080808060043561136660018060a01b03835460101c1633146118db565b61137281471015612704565b335af161137d611ef8565b501561138557005b60405162461bcd60e51b815260206004820152601f60248201527f537761707065723a206e6174697665207769746864726177206661696c6564006044820152606490fd5b346103385760003660031901126103385760206040516127108152f35b3461033857602036600319011261033857600435600a5481101561033857600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a801546040516001600160a01b039091168152602090f35b34610338576020366003190112610338576001600160a01b03611463611832565b1660005260096020526020604060002054604051908152f35b34610338576000366003190112610338576001546040516001600160a01b039091168152602090f35b34610338576000366003190112610338576006546040516001600160a01b039091168152602090f35b34610338576020366003190112610338576004356114fa60018060a01b0360005460101c1633146118db565b612710811161152e5780600c557f9c922f6d0c990b250e9dd0a427a5c8da7f44b960f697fecb31cbbd8ba79ec8c2600080a2005b60405162461bcd60e51b815260206004820152603860248201527f537761707065723a206d617820736c697070616765206d757374206265206c6560448201527f7373207468616e206f7220657175616c20746f203130302500000000000000006064820152608490fd5b346103385760003660031901126103385760018060a01b036115c38160005460101c1633146118db565b80600654166040519163bf40fac160e01b90818452602093846004820152600960248201526846756e6453746f726560b81b60448201528481606481875afa801561032c57829160009161179b575b5016926bffffffffffffffffffffffff60a01b928484600754161760075560405190808252866004830152600c60248301526b4275794261636b53746f726560a01b60448301528682606481865afa91821561032c578792859160009161177e575b5016856008541617600855604051928391825281806116b06004820160609060208152600560208201526450494e475560d81b60408201520190565b03915afa90811561032c57600091611761575b506002805491909216921682179055604051636eb1769f60e11b81523060048201526001600160a01b03831660248201528381604481855afa93841561032c57600094611731575b5050600019831061171857005b61001b9215611d04575b61172c8282611cc9565b611d04565b9080929450813d831161175a575b6117498183611a8c565b81010312610338575191838061170b565b503d61173f565b6117789150853d8711611166576111588183611a8c565b856116c3565b6117959150843d8611611166576111588183611a8c565b89611674565b6117b29150863d8811611166576111588183611a8c565b86611612565b346103385760003660031901126103385760005460405160109190911c6001600160a01b03168152602090f35b34610338576000366003190112610338576007546040516001600160a01b039091168152602090f35b34610338576000366003190112610338576008546001600160a01b03168152602090f35b600435906001600160a01b038216820361033857565b602435906001600160a01b038216820361033857565b600a5481101561189557600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80190600090565b634e487b7160e01b600052603260045260246000fd5b9181601f84011215610338578235916001600160401b038311610338576020808501948460051b01011161033857565b156118e257565b606460405162461bcd60e51b815260206004820152600460248201526310b3b7bb60e11b6044820152fd5b6001600160a01b038181161561198a576000805462010000600160b01b03198116601085811b62010000600160b01b031691909117909255604080516001600160a01b039290931c939093168116825290921660208301527f53351836099c03ffc3b1727d8abd4b0222afa87d4ed76ae3102d51369ef7f78591a1565b60405162461bcd60e51b815260206004820152600960248201526810bd32b93796b3b7bb60b91b6044820152606490fd5b156119c257565b60405162461bcd60e51b815260206004820152601760248201527f537761707065723a20726f75746572206973207a65726f0000000000000000006044820152606490fd5b15611a0e57565b60405162461bcd60e51b815260206004820152602260248201527f537761707065723a20726f75746572206d757374206265206120636f6e74726160448201526118dd60f21b6064820152608490fd5b6001600160401b038111610c5a57604052565b608081019081106001600160401b03821117610c5a57604052565b90601f801991011681019081106001600160401b03821117610c5a57604052565b9081602091031261033857516001600160a01b03811681036103385790565b60001981146108975760010190565b91908110156118955760051b0190565b356001600160a01b03811681036103385790565b8181029291811591840414171561089757565b90816020910312610338575180151581036103385790565b6001600160401b038111610c5a5760051b60200190565b6020908181840312610338578051906001600160401b03821161033857019180601f84011215610338578251611b7681611b2a565b93611b846040519586611a8c565b818552838086019260051b820101928311610338578301905b828210611bab575050505090565b81518152908301908301611b9d565b90815180825260208080930193019160005b828110611bda575050505090565b83516001600160a01b031685529381019392810192600101611bcc565b8051156118955760200190565b8051600110156118955760400190565b8051600210156118955760600190565b80518210156118955760209160051b010190565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529093911690602084604481855afa93841561032c57600094611c93575b508310611c8457505050565b611c919261172257611d04565b565b90936020823d8211611cc1575b81611cad60209383611a8c565b81010312611cbe5750519238611c78565b80fd5b3d9150611ca0565b60405163095ea7b360e01b60208201526001600160a01b03909216602483015260006044808401919091528252611c9191906112b082611a71565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529293926020929183816044818686165afa90811561032c57600091611de0575b50611d7c57611c9193946040519363095ea7b360e01b908501521660248301526000196044830152604482526112b082611a71565b60405162461bcd60e51b815260048101849052603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608490fd5b908482813d8311611e06575b611df68183611a8c565b81010312611cbe57505138611d47565b503d611dec565b60408051908101916001600160a01b03166001600160401b03831182841017610c5a57611e7c926040526000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af1611e76611ef8565b91611f37565b80519081611e8957505050565b8280611e99938301019101611b12565b15611ea15750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b3d15611f32573d906001600160401b038211610c5a5760405191611f26601f8201601f191660200184611a8c565b82523d6000602084013e565b606090565b91929015611f995750815115611f4b575090565b3b15611f545790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015611fac5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510611ff2575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350611fcf565b6001600160a01b039080821690811561245a578260025416801561241d578360055416156123d8578083146123ac57612044818361249f565b61236c57600a5490600193848301948584116108975761206386611b2a565b9460409661207388519788611a8c565b808752612082601f1991611b2a565b0197602098368a8901376000956003938285541680151580612362575b80612358575b612344575b5060005b8281106122935750505060005b868110612203575060005b8681106120fa5750505050505050508051918201908282106001600160401b03831117610c5a575260008152600036813790565b81612105828a611c24565b5116612111818561249f565b156121f95760005b88811061213057505061212b90611acc565b6120c6565b8281146121f05783612142828c611c24565b511661214e818461249f565b806121e0575b612167575061216290611acc565b612119565b9698505093959899975050505086519660a08801908882106001600160401b03831117610c5a57526004938488526080809636908a01376121a788611bf7565b526121b187611c04565b526121bb86611c14565b52845111156121cb575082015290565b603290634e487b7160e01b6000525260246000fd5b506121eb898261249f565b612154565b61216290611acc565b5061212b90611acc565b8161220e828a611c24565b511661221a818561249f565b80612283575b612233575061222e90611acc565b6120bb565b9750505050959092508491945195608087018781106001600160401b03821117610c5a57606093528652369086013761226b84611bf7565b5261227583611c04565b5261227f82611c14565b5290565b5061228e878261249f565b612220565b8361229d8261185e565b905490881b1c168015801561233b575b8015612332575b612328576000805b868d8d83106122f9575b505050906122da9291156122df5750611acc565b6120ae565b6122f26122eb8c611acc565b9b8d611c24565b52386107c0565b90612305838693611c24565b51161461231a5761231590611acc565b6122bc565b508390506122da868d6122c6565b506122da90611acc565b508881146122b4565b508781146122ad565b975080976123518a611bf7565b52386120aa565b50878114156120a5565b508681141561209f565b9192505060405191606083018381106001600160401b03821117610c5a576040526002835260403660208501376123a283611bf7565b5261227f82611c04565b50505050604051602081018181106001600160401b03821117610c5a5760405260008152600036813790565b60405162461bcd60e51b815260206004820152601860248201527f537761707065723a20666163746f7279206e6f742073657400000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601560248201527414ddd85c1c195c8e8818985cd9481b9bdd081cd95d605a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601860248201527f537761707065723a20746f6b656e496e206973207a65726f00000000000000006044820152606490fd5b60055460405163e6a4390560e01b81526001600160a01b03928316600482015292821660248401529091906020908290604490829086165afa90811561032c576000916124ee575b5016151590565b612506915060203d8111611166576111588183611a8c565b386124e7565b6040805163c45a015560e01b815290916001600160a01b03916020918316908281600481855afa9081156126f9576000916126dc575b508381169081151590816126d1575b501561268d576004918391600554868116828103612650575b5050508551928380926315ab88c960e31b82525afa90811561264557908391600091612628575b50169283156125e55750506003549081168281036125ae57505050565b82907f9a840e37cdc9259cd902f02ce82539dcac055dd28cabd649612afaba13a89206600080a36001600160a01b03191617600355565b60649250519062461bcd60e51b82526004820152601860248201527f537761707065723a20696e76616c696420574e617469766500000000000000006044820152fd5b61263f9150833d8511611166576111588183611a8c565b38612591565b84513d6000823e3d90fd5b82907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb555600080a36001600160a01b0319161760055538808061256a565b845162461bcd60e51b815260048101849052601860248201527f537761707065723a20696e76616c696420666163746f727900000000000000006044820152606490fd5b90503b151538612551565b6126f39150833d8511611166576111588183611a8c565b38612542565b85513d6000823e3d90fd5b1561270b57565b60405162461bcd60e51b815260206004820152601d60248201527f537761707065723a20696e73756666696369656e742062616c616e63650000006044820152606490fdfea26469706673582212209a33b7e1dfed5079f2aed49215c7af83fdf43f95e1e9871b6841b3a4df74849464736f6c63430008110033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in MON
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.