ERC-20
Overview
Max Total Supply
6,219,301.827 ERC20 ***
Holders
48
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 3 Decimals)
Balance
100 ERC20 ***Value
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
Pool
Compiler Version
v0.8.18+commit.87f61d96
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {RewardManager} from "./RewardManager.sol"; /** * 4AD - D = 4A(x + y) - (D³ / 4xy) * X - is value of real stable token * Y - is value of virtual usd */ contract Pool is RewardManager { using SafeERC20 for ERC20; uint private constant SYSTEM_PRECISION = 3; int private constant PP = 1e4; // Price Precision uint private constant MAX_TOKEN_BALANCE = 2 ** 40; // Max possible token balance /** * @dev Gas optimization: both the 'feeShareBP' and 'router' fields are used during the 'swapFromVUsd', 'swapToVUsd' * operations and can occupy the same slot. */ uint16 public feeShareBP; address public router; uint public tokenBalance; uint public vUsdBalance; uint public balanceRatioMinBP; uint public reserves; uint public immutable a; uint public d; uint private immutable tokenAmountReduce; uint private immutable tokenAmountIncrease; // can restrict deposit or withdraw operations address private stopAuthority; // is deposit operation allowed uint public canDeposit = 1; // is withdraw operation allowed uint public canWithdraw = 1; event SwappedToVUsd(address sender, address token, uint amount, uint vUsdAmount, uint fee); event SwappedFromVUsd(address recipient, address token, uint vUsdAmount, uint amount, uint fee); constructor( address router_, uint a_, ERC20 token_, uint16 feeShareBP_, uint balanceRatioMinBP_, string memory lpName, string memory lpSymbol ) RewardManager(token_, lpName, lpSymbol) { a = a_; router = router_; stopAuthority = owner(); feeShareBP = feeShareBP_; balanceRatioMinBP = balanceRatioMinBP_; uint decimals = token_.decimals(); tokenAmountReduce = decimals > SYSTEM_PRECISION ? 10 ** (decimals - SYSTEM_PRECISION) : 0; tokenAmountIncrease = decimals < SYSTEM_PRECISION ? 10 ** (SYSTEM_PRECISION - decimals) : 0; } /** * @dev Throws if called by any account other than the router. */ modifier onlyRouter() { require(router == msg.sender, "Pool: is not router"); _; } /** * @dev Throws if called by any account other than the stopAuthority. */ modifier onlyStopAuthority() { require(stopAuthority == msg.sender, "Pool: is not stopAuthority"); _; } /** * @dev Modifier to prevent function from disbalancing the pool over a threshold defined by `balanceRatioMinBP` */ modifier validateBalanceRatio() { _; if (tokenBalance > vUsdBalance) { require((vUsdBalance * BP) / tokenBalance >= balanceRatioMinBP, "Pool: low vUSD balance"); } else if (tokenBalance < vUsdBalance) { require((tokenBalance * BP) / vUsdBalance >= balanceRatioMinBP, "Pool: low token balance"); } } /** * @dev Modifier to make a function callable only when the deposit is allowed. */ modifier whenCanDeposit() { require(canDeposit == 1, "Pool: deposit prohibited"); _; } /** * @dev Modifier to make a function callable only when the withdraw is allowed. */ modifier whenCanWithdraw() { require(canWithdraw == 1, "Pool: withdraw prohibited"); _; } /** * @dev Calculates the price and deposit token according to the amount and price, then adds the same amount to the X * and to the Y * @param amount The deposited amount */ function deposit(uint amount) external whenCanDeposit { uint oldD = d; uint amountSP = _toSystemPrecision(amount); require(amountSP > 0, "Pool: too little"); token.safeTransferFrom(msg.sender, address(this), amount); // Add deposited amount to reserves reserves += amountSP; uint oldBalance = (tokenBalance + vUsdBalance); if (oldD == 0 || oldBalance == 0) { // Split balance equally on the first deposit uint halfAmount = amountSP >> 1; tokenBalance += halfAmount; vUsdBalance += halfAmount; } else { // Add amount proportionally to each pool tokenBalance += (amountSP * tokenBalance) / oldBalance; vUsdBalance += (amountSP * vUsdBalance) / oldBalance; } _updateD(); // Deposit as many LP tokens as the D increase _depositLp(msg.sender, d - oldD); require(tokenBalance < MAX_TOKEN_BALANCE, "Pool: too much"); } /* * @dev Subtracts X and Y for that amount, calculates current price and withdraw the token to the user according to * the price * @param amount The deposited amount */ function withdraw(uint amountLp) external whenCanWithdraw { uint oldD = d; _withdrawLp(msg.sender, amountLp); // Always withdraw tokens in amount equal to amountLp // Withdraw proportionally from token and vUsd balance uint oldBalance = (tokenBalance + vUsdBalance); tokenBalance -= (amountLp * tokenBalance) / oldBalance; vUsdBalance -= (amountLp * vUsdBalance) / oldBalance; require(tokenBalance + vUsdBalance < oldBalance, "Pool: zero changes"); // Check if there is enough funds in reserve to withdraw require(amountLp <= reserves, "Pool: reserves"); // Adjust reserves by withdraw amount reserves -= amountLp; // Update D and transfer tokens to the sender _updateD(); require(d < oldD, "Pool: zero D changes"); token.safeTransfer(msg.sender, _fromSystemPrecision(amountLp)); } /** * @notice Calculates new virtual USD value from the given amount of tokens. * @dev Calculates new Y according to new X. * NOTICE: Prior to calling this the router must transfer tokens from the user to the pool. * @param amount The amount of tokens to swap. * @param zeroFee When true it allows to swap without incurring any fees. It is intended for use with service * accounts. * @return returns the difference between the old and the new value of vUsdBalance */ function swapToVUsd( address user, uint amount, bool zeroFee ) external onlyRouter validateBalanceRatio returns (uint) { uint result; // 0 by default uint fee; if (amount > 0) { if (!zeroFee) { fee = (amount * feeShareBP) / BP; } uint amountIn = _toSystemPrecision(amount - fee); // Incorporate rounding dust into the fee fee = amount - _fromSystemPrecision(amountIn); // Adjust token and reserve balances after the fee is applied tokenBalance += amountIn; reserves += amountIn; uint vUsdNewAmount = this.getY(tokenBalance); if (vUsdBalance > vUsdNewAmount) { result = vUsdBalance - vUsdNewAmount; } vUsdBalance = vUsdNewAmount; _addRewards(fee); } emit SwappedToVUsd(user, address(token), amount, result, fee); return result; } /** * @notice Calculates the amount of tokens from the given virtual USD value, and transfers it to the user. * @dev Calculates new X according to new Y. * @param user The address of the recipient. * @param amount The amount of vUSD to swap. * @param receiveAmountMin The minimum amount of tokens required to be received during the swap, otherwise the * transaction reverts. * @param zeroFee When true it allows to swap without incurring any fees. It is intended for use with service * accounts. * @return returns the difference between the old and the new value of vUsdBalance */ function swapFromVUsd( address user, uint amount, uint receiveAmountMin, bool zeroFee ) external onlyRouter validateBalanceRatio returns (uint) { uint resultSP; // 0 by default uint result; // 0 by default uint fee; if (amount > 0) { vUsdBalance += amount; uint newAmount = this.getY(vUsdBalance); if (tokenBalance > newAmount) { resultSP = tokenBalance - newAmount; result = _fromSystemPrecision(resultSP); } // Otherwise result/resultSP stay 0 // Check if there is enough funds in reserve to pay require(resultSP <= reserves, "Pool: reserves"); // Remove from reserves including fee, apply fee later reserves -= resultSP; if (!zeroFee) { fee = (result * feeShareBP) / BP; } // We can use unchecked here because feeShareBP <= BP unchecked { result -= fee; } tokenBalance = newAmount; require(result >= receiveAmountMin, "Pool: slippage"); token.safeTransfer(user, result); _addRewards(fee); } emit SwappedFromVUsd(user, address(token), amount, result, fee); return result; } /** * @dev Sets admin fee share. */ function setFeeShare(uint16 feeShareBP_) external onlyOwner { require(feeShareBP_ <= BP, "Pool: too large"); feeShareBP = feeShareBP_; } function adjustTotalLpAmount() external onlyOwner { if (d > totalSupply()) { _depositLp(owner(), d - totalSupply()); } } /** * @dev Sets the threshold over which the pool can't be disbalanced. */ function setBalanceRatioMinBP(uint balanceRatioMinBP_) external onlyOwner { require(balanceRatioMinBP_ <= BP, "Pool: too large"); balanceRatioMinBP = balanceRatioMinBP_; } /** * @dev Switches off the possibility to make deposits. */ function stopDeposit() external onlyStopAuthority { canDeposit = 0; } /** * @dev Switches on the possibility to make deposits. */ function startDeposit() external onlyOwner { canDeposit = 1; } /** * @dev Switches off the possibility to make withdrawals. */ function stopWithdraw() external onlyStopAuthority { canWithdraw = 0; } /** * @dev Switches on the possibility to make withdrawals. */ function startWithdraw() external onlyOwner { canWithdraw = 1; } /** * @dev Sets the address of the stopAuthority account. */ function setStopAuthority(address stopAuthority_) external onlyOwner { stopAuthority = stopAuthority_; } /** * @dev Sets the address of the Router contract. */ function setRouter(address router_) external onlyOwner { router = router_; } /** * @dev y = (sqrt(x(4AD³ + x (4A(D - x) - D )²)) + x (4A(D - x) - D ))/8Ax. */ function getY(uint x) external view returns (uint) { uint d_ = d; // Gas optimization uint a4 = a << 2; uint a8 = a4 << 1; // 4A(D - x) - D int part1 = int(a4) * (int(d_) - int(x)) - int(d_); // x * (4AD³ + x(part1²)) uint part2 = x * (a4 * d_ * d_ * d_ + x * uint(part1 * part1)); // (sqrt(part2) + x(part1)) / 8Ax) return SafeCast.toUint256(int(_sqrt(part2)) + int(x) * part1) / (a8 * x) + 1; // +1 to offset rounding errors } /** * @dev price = (1/2) * ((D³ + 8ADx² - 8Ax³ - 2Dx²) / (4x * sqrt(x(4AD³ + x (4A(D - x) - D )²)))) */ function getPrice() external view returns (uint) { uint x = tokenBalance; uint a8 = a << 3; uint dCubed = d * d * d; // 4A(D - x) - D int p1 = int(a << 2) * (int(d) - int(x)) - int(d); // x * 4AD³ + x(p1²) uint p2 = x * ((a << 2) * dCubed + x * uint(p1 * p1)); // D³ + 8ADx² - 8Ax³ - 2Dx² int p3 = int(dCubed) + int((a << 3) * d * x * x) - int(a8 * x * x * x) - int((d << 1) * x * x); // 1/2 * p3 / (4x * sqrt(p2)) return SafeCast.toUint256((PP >> 1) + ((PP * p3) / int((x << 2) * _sqrt(p2)))); } function _updateD() internal { uint x = tokenBalance; uint y = vUsdBalance; // a = 8 * Axy(x+y) // b = 4 * xy(4A - 1) / 3 // c = sqrt(a² + b³) // D = cbrt(a + c) + cbrt(a - c) uint xy = x * y; uint a_ = a; // Axy(x+y) uint p1 = a_ * xy * (x + y); // xy(4A - 1) / 3 uint p2 = (xy * ((a_ << 2) - 1)) / 3; // p1² + p2³ uint p3 = _sqrt((p1 * p1) + (p2 * p2 * p2)); unchecked { uint d_ = _cbrt(p1 + p3); if (p3 > p1) { d_ -= _cbrt(p3 - p1); } else { d_ += _cbrt(p1 - p3); } d = (d_ << 1); } } function _toSystemPrecision(uint amount) internal view returns (uint) { if (tokenAmountReduce > 0) { return amount / tokenAmountReduce; } else if (tokenAmountIncrease > 0) { return amount * tokenAmountIncrease; } return amount; } function _fromSystemPrecision(uint amount) internal view returns (uint) { if (tokenAmountReduce > 0) { return amount * tokenAmountReduce; } else if (tokenAmountIncrease > 0) { return amount / tokenAmountIncrease; } return amount; } function _sqrt(uint n) internal pure returns (uint) { unchecked { if (n > 0) { uint x = (n >> 1) + 1; uint y = (x + n / x) >> 1; while (x > y) { x = y; y = (x + n / x) >> 1; } return x; } return 0; } } function _cbrt(uint n) internal pure returns (uint) { unchecked { uint x = 0; for (uint y = 1 << 255; y > 0; y >>= 3) { x <<= 1; uint z = 3 * x * (x + 1) + 1; if (n / y >= z) { n -= y * z; x += 1; } } return x; } } fallback() external payable { revert("Unsupported"); } receive() external payable { revert("Unsupported"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// 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"); } } }
// 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 v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IBridge, MessengerProtocol} from "./interfaces/IBridge.sol"; import {Router} from "./Router.sol"; import {Messenger} from "./Messenger.sol"; import {MessengerGateway} from "./MessengerGateway.sol"; import {IGasOracle} from "./interfaces/IGasOracle.sol"; import {GasUsage} from "./GasUsage.sol"; import {WormholeMessenger} from "./WormholeMessenger.sol"; import {HashUtils} from "./libraries/HashUtils.sol"; /** * @title Bridge * @dev A contract with functions to facilitate bridging tokens across different blockchains. */ contract Bridge is GasUsage, Router, MessengerGateway, IBridge { using SafeERC20 for IERC20; using HashUtils for bytes32; uint public immutable override chainId; mapping(bytes32 messageHash => uint isProcessed) public override processedMessages; mapping(bytes32 messageHash => uint isSent) public override sentMessages; // Info about bridges on other chains mapping(uint chainId => bytes32 bridgeAddress) public override otherBridges; // Info about tokens on other chains mapping(uint chainId => mapping(bytes32 tokenAddress => bool isSupported)) public override otherBridgeTokens; /** * @dev Emitted when tokens are sent on the source blockchain. */ event TokensSent( uint amount, bytes32 recipient, uint destinationChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger ); /** * @dev Emitted when the tokens are received on the destination blockchain. */ event TokensReceived(uint amount, bytes32 recipient, uint nonce, MessengerProtocol messenger, bytes32 message); /** * @dev Emitted when this contract receives the bridging fee. */ event ReceiveFee(uint bridgeTransactionCost, uint messageTransactionCost); /** * @dev Emitted when this contract charged the sender with the tokens for the bridging fee. */ event BridgingFeeFromTokens(uint gas); /** * @dev Emitted when the contract receives native tokens (e.g. Ether on the Ethereum network) from the admin to * supply the gas for bridging. */ event Received(address sender, uint amount); constructor( uint chainId_, uint chainPrecision_, Messenger allbridgeMessenger_, WormholeMessenger wormholeMessenger_, IGasOracle gasOracle_ ) Router(chainPrecision_) MessengerGateway(allbridgeMessenger_, wormholeMessenger_) GasUsage(gasOracle_) { chainId = chainId_; } /** * @notice Initiates a swap and bridge process of a given token for a token on another blockchain. * @dev This function is used to initiate a cross-chain transfer. The specified amount of token is first transferred * to the pool on the current chain, and then an event `TokensSent` is emitted to signal that tokens have been sent * on the source chain. See the function `receiveTokens`. * The bridging fee required for the cross-chain transfer can be paid in two ways: * - by sending the required amount of native gas token along with the transaction * (See `getTransactionCost` in the `GasUsage` contract and `getMessageCost` in the `MessengerGateway` contract). * - by setting the parameter `feeTokenAmount` with the bridging fee amount in the source tokens * (See the function `getBridgingCostInTokens`). * @param token The token to be swapped. * @param amount The amount of tokens to be swapped (including `feeTokenAmount`). * @param destinationChainId The ID of the destination chain. * @param receiveToken The token to receive in exchange for the swapped token. * @param nonce An identifier that is used to ensure that each transfer is unique and can only be processed once. * @param messenger The chosen way of delivering the message across chains. * @param feeTokenAmount The amount of tokens to be deducted from the transferred amount as a bridging fee. * */ function swapAndBridge( bytes32 token, uint amount, bytes32 recipient, uint destinationChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger, uint feeTokenAmount ) external payable override whenCanSwap { require(amount > feeTokenAmount, "Bridge: amount too low for fee"); require(recipient != 0, "Bridge: bridge to the zero address"); uint bridgingFee = msg.value + _convertBridgingFeeInTokensToNativeToken(msg.sender, token, feeTokenAmount); uint amountAfterFee = amount - feeTokenAmount; uint vUsdAmount = _sendAndSwapToVUsd(token, msg.sender, amountAfterFee); _sendTokens(vUsdAmount, recipient, destinationChainId, receiveToken, nonce, messenger, bridgingFee); } /** * @notice Completes the bridging process by sending the tokens on the destination chain to the recipient. * @dev This function is called only after a bridging has been initiated by a user * through the `swapAndBridge` function on the source chain. * @param amount The amount of tokens being bridged. * @param recipient The recipient address for the bridged tokens. * @param sourceChainId The ID of the source chain. * @param receiveToken The address of the token being received. * @param nonce A unique nonce for the bridging transaction. * @param messenger The protocol used to relay the message. * @param receiveAmountMin The minimum amount of receiveToken required to be received. */ function receiveTokens( uint amount, bytes32 recipient, uint sourceChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger, uint receiveAmountMin ) external payable override whenCanSwap { require(otherBridges[sourceChainId] != bytes32(0), "Bridge: source not registered"); bytes32 messageWithSender = this .hashMessage(amount, recipient, sourceChainId, chainId, receiveToken, nonce, messenger) .hashWithSender(otherBridges[sourceChainId]); require(processedMessages[messageWithSender] == 0, "Bridge: message processed"); // mark the transfer as received on the destination chain processedMessages[messageWithSender] = 1; // check if tokens has been sent on the source chain require(this.hasReceivedMessage(messageWithSender, messenger), "Bridge: no message"); uint receiveAmount = _receiveAndSwapFromVUsd( receiveToken, address(uint160(uint(recipient))), amount, receiveAmountMin ); // pass extra gas to the recipient if (msg.value > 0) { // ignore if passing extra gas failed // solc-ignore-next-line unused-call-retval payable(address(uint160(uint(recipient)))).call{value: msg.value}(""); } emit TokensReceived(receiveAmount, recipient, nonce, messenger, messageWithSender); } /** * @notice Allows the admin to add new supported chain destination. * @dev Registers the address of a bridge deployed on a different chain. * @param chainId_ The chain ID of the bridge to register. * @param bridgeAddress The address of the bridge contract to register. */ function registerBridge(uint chainId_, bytes32 bridgeAddress) external override onlyOwner { otherBridges[chainId_] = bridgeAddress; } /** * @notice Allows the admin to add a new supported destination token. * @dev Adds the address of a token on another chain to the list of supported tokens for the specified chain. * @param chainId_ The chain ID where the token is deployed. * @param tokenAddress The address of the token to add as a supported token. */ function addBridgeToken(uint chainId_, bytes32 tokenAddress) external override onlyOwner { otherBridgeTokens[chainId_][tokenAddress] = true; } /** * @notice Allows the admin to remove support for a destination token. * @dev Removes the address of a token on another chain from the list of supported tokens for the specified chain. * @param chainId_ The chain ID where the token is deployed. * @param tokenAddress The address of the token to remove from the list of supported tokens. */ function removeBridgeToken(uint chainId_, bytes32 tokenAddress) external override onlyOwner { otherBridgeTokens[chainId_][tokenAddress] = false; } /** * @notice Allows the admin to withdraw the bridging fee collected in native tokens. */ function withdrawGasTokens(uint amount) external override onlyOwner { payable(msg.sender).transfer(amount); } /** * @notice Allows the admin to withdraw the bridging fee collected in tokens. * @param token The address of the token contract. */ function withdrawBridgingFeeInTokens(IERC20 token) external onlyOwner { uint toWithdraw = token.balanceOf(address(this)); if (toWithdraw > 0) { token.safeTransfer(msg.sender, toWithdraw); } } /** * @dev Calculates the amount of bridging fee nominated in a given token, which includes: * - the gas cost of making the receive transaction on the destination chain, * - the gas cost of sending the message to the destination chain using the specified messenger protocol. * @param destinationChainId The ID of the destination chain. * @param messenger The chosen way of delivering the message across chains. * @param tokenAddress The address of the token contract on the source chain. * @return The total price of bridging, with the precision according to the token's `decimals()` value. */ function getBridgingCostInTokens( uint destinationChainId, MessengerProtocol messenger, address tokenAddress ) external view override returns (uint) { return gasOracle.getTransactionGasCostInUSD( destinationChainId, gasUsage[destinationChainId] + getMessageGasUsage(destinationChainId, messenger) ) / fromGasOracleScalingFactor[tokenAddress]; } /** * @dev Produces a hash of transfer parameters, which is used as a message to the bridge on the destination chain * to notify that the tokens on the source chain has been sent. * @param amount The amount of tokens being transferred. * @param recipient The address of the recipient on the destination chain. * @param sourceChainId The ID of the source chain. * @param destinationChainId The ID of the destination chain. * @param receiveToken The token being received on the destination chain. * @param nonce The unique nonce. * @param messenger The chosen way of delivering the message across chains. */ function hashMessage( uint amount, bytes32 recipient, uint sourceChainId, uint destinationChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger ) external pure override returns (bytes32) { return keccak256(abi.encodePacked(amount, recipient, sourceChainId, receiveToken, nonce, messenger)) .replaceChainBytes(uint8(sourceChainId), uint8(destinationChainId)); } function _sendTokens( uint amount, bytes32 recipient, uint destinationChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger, uint bridgingFee ) internal { require(destinationChainId != chainId, "Bridge: wrong destination chain"); require(otherBridgeTokens[destinationChainId][receiveToken], "Bridge: unknown chain or token"); bytes32 message = this.hashMessage( amount, recipient, chainId, destinationChainId, receiveToken, nonce, messenger ); require(sentMessages[message] == 0, "Bridge: tokens already sent"); // mark the transfer as sent on the source chain sentMessages[message] = 1; uint bridgeTransactionCost = this.getTransactionCost(destinationChainId); uint messageTransactionCost = _sendMessage(message, messenger); emit ReceiveFee(bridgeTransactionCost, messageTransactionCost); unchecked { require(bridgingFee >= bridgeTransactionCost + messageTransactionCost, "Bridge: not enough fee"); } emit TokensSent(amount, recipient, destinationChainId, receiveToken, nonce, messenger); } /** * @dev Charges the bridging fee in tokens and calculates the amount of native tokens that correspond * to the charged fee using the current exchange rate. * @param user The address of the user who is paying the bridging fee * @param tokenAddress The address of the token used to pay the bridging fee * @param feeTokenAmount The amount of tokens to pay as the bridging fee * @return bridging fee amount in the native tokens (e.g. in wei for Ethereum) */ function _convertBridgingFeeInTokensToNativeToken( address user, bytes32 tokenAddress, uint feeTokenAmount ) internal returns (uint) { if (feeTokenAmount == 0) return 0; address tokenAddress_ = address(uint160(uint(tokenAddress))); IERC20 token = IERC20(tokenAddress_); token.safeTransferFrom(user, address(this), feeTokenAmount); uint fee = (bridgingFeeConversionScalingFactor[tokenAddress_] * feeTokenAmount) / gasOracle.price(chainId); emit BridgingFeeFromTokens(fee); return fee; } fallback() external payable { revert("Unsupported"); } receive() external payable { emit Received(msg.sender, msg.value); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IGasOracle} from "./interfaces/IGasOracle.sol"; /** * @title GasOracle * @dev A contract that provides gas price and native token USD price data on other blockchains. */ contract GasOracle is Ownable, IGasOracle { struct ChainData { // price of the chain's native token in USD uint128 price; // price of a gas unit in the chain's native token with precision according to the const ORACLE_PRECISION uint128 gasPrice; } uint private constant ORACLE_PRECISION = 18; uint private constant ORACLE_SCALING_FACTOR = 10 ** ORACLE_PRECISION; // number to divide by to change precision from gas oracle price precision to chain precision uint private immutable fromOracleToChainScalingFactor; mapping(uint chainId => ChainData) public override chainData; // current chain ID uint public immutable override chainId; constructor(uint chainId_, uint chainPrecision) { chainId = chainId_; fromOracleToChainScalingFactor = 10 ** (ORACLE_PRECISION - chainPrecision); } /** * @notice Sets the chain data for a given chain ID. * @param chainId_ The ID of the given chain to set data for. * @param price_ The price of the given chain's native token in USD. * @param gasPrice The price of a gas unit in the given chain's native token (with precision according to the const * `ORACLE_PRECISION`). */ function setChainData(uint chainId_, uint128 price_, uint128 gasPrice) external override onlyOwner { chainData[chainId_].price = price_; chainData[chainId_].gasPrice = gasPrice; } /** * @notice Sets only the price for a given chain ID. * @param chainId_ The ID of the given chain to set the price for. * @param price_ The price of the given chain's native token in USD. */ function setPrice(uint chainId_, uint128 price_) external override onlyOwner { chainData[chainId_].price = price_; } /** * @notice Sets only the gas price for a given chain ID. * @param chainId_ The ID of the given chain to set the gas price for. * @param gasPrice The price of a gas unit in the given chain's native token (with precision according to the const * `ORACLE_PRECISION`). */ function setGasPrice(uint chainId_, uint128 gasPrice) external override onlyOwner { chainData[chainId_].gasPrice = gasPrice; } /** * @notice Calculates the gas cost of a transaction on another chain in the current chain's native token. * @param otherChainId The ID of the chain for which to get the gas cost. * @param gasAmount The amount of gas used in a transaction. * @return The gas cost of a transaction in the current chain's native token */ function getTransactionGasCostInNativeToken( uint otherChainId, uint gasAmount ) external view override returns (uint) { return (chainData[otherChainId].gasPrice * gasAmount * chainData[otherChainId].price) / chainData[chainId].price / fromOracleToChainScalingFactor; } /** * @notice Calculates the gas cost of a transaction on another chain in USD. * @param otherChainId The ID of the chain for which to get the gas cost. * @param gasAmount The amount of gas used in a transaction. * @return The gas cost of a transaction in USD with precision of `ORACLE_PRECISION` */ function getTransactionGasCostInUSD(uint otherChainId, uint gasAmount) external view override returns (uint) { return (chainData[otherChainId].gasPrice * gasAmount * chainData[otherChainId].price) / ORACLE_SCALING_FACTOR; } /** * @notice Get the cross-rate between the two chains' native tokens. * @param otherChainId The ID of the other chain to get the cross-rate for. */ function crossRate(uint otherChainId) external view override returns (uint) { return (chainData[otherChainId].price * ORACLE_SCALING_FACTOR) / chainData[chainId].price; } /** * @notice Get the price of a given chain's native token in USD. * @param chainId_ The ID of the given chain to get the price. * @return the price of the given chain's native token in USD with precision of const ORACLE_PRECISION */ function price(uint chainId_) external view override returns (uint) { return chainData[chainId_].price; } fallback() external payable { revert("Unsupported"); } receive() external payable { revert("Unsupported"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IGasOracle} from "./interfaces/IGasOracle.sol"; /** * @dev Contract module which allows children to store typical gas usage of a certain transaction on another chain. */ abstract contract GasUsage is Ownable { IGasOracle internal gasOracle; mapping(uint chainId => uint amount) public gasUsage; constructor(IGasOracle gasOracle_) { gasOracle = gasOracle_; } /** * @dev Sets the amount of gas used for a transaction on a given chain. * @param chainId The ID of the chain. * @param gasAmount The amount of gas used on the chain. */ function setGasUsage(uint chainId, uint gasAmount) external onlyOwner { gasUsage[chainId] = gasAmount; } /** * @dev Sets the Gas Oracle contract address. * @param gasOracle_ The address of the Gas Oracle contract. */ function setGasOracle(IGasOracle gasOracle_) external onlyOwner { gasOracle = gasOracle_; } /** * @notice Get the gas cost of a transaction on another chain in the current chain's native token. * @param chainId The ID of the chain for which to get the gas cost. * @return The calculated gas cost of the transaction in the current chain's native token */ function getTransactionCost(uint chainId) external view returns (uint) { unchecked { return gasOracle.getTransactionGasCostInNativeToken(chainId, gasUsage[chainId]); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; enum MessengerProtocol { None, Allbridge, Wormhole, LayerZero } interface IBridge { function chainId() external view returns (uint); function processedMessages(bytes32) external view returns (uint); function sentMessages(bytes32) external view returns (uint); function otherBridges(uint) external view returns (bytes32); function otherBridgeTokens(uint, bytes32) external view returns (bool); function getBridgingCostInTokens( uint destinationChainId, MessengerProtocol messenger, address tokenAddress ) external view returns (uint); function hashMessage( uint amount, bytes32 recipient, uint sourceChainId, uint destinationChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger ) external pure returns (bytes32); function receiveTokens( uint amount, bytes32 recipient, uint sourceChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger, uint receiveAmountMin ) external payable; function withdrawGasTokens(uint amount) external; function registerBridge(uint chainId, bytes32 bridgeAddress) external; function addBridgeToken(uint chainId, bytes32 tokenAddress) external; function removeBridgeToken(uint chainId, bytes32 tokenAddress) external; function swapAndBridge( bytes32 token, uint amount, bytes32 recipient, uint destinationChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger, uint feeTokenAmount ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; interface IGasOracle { function chainData(uint chainId) external view returns (uint128 price, uint128 gasPrice); function chainId() external view returns (uint); function crossRate(uint otherChainId) external view returns (uint); function getTransactionGasCostInNativeToken(uint otherChainId, uint256 gasAmount) external view returns (uint); function getTransactionGasCostInUSD(uint otherChainId, uint256 gasAmount) external view returns (uint); function price(uint chainId) external view returns (uint); function setChainData(uint chainId, uint128 price, uint128 gasPrice) external; function setGasPrice(uint chainId, uint128 gasPrice) external; function setPrice(uint chainId, uint128 price) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; interface IMessenger { function sentMessagesBlock(bytes32 message) external view returns (uint); function receivedMessages(bytes32 message) external view returns (uint); function sendMessage(bytes32 message) external payable; function receiveMessage(bytes32 message, uint v1v2, bytes32 r1, bytes32 s1, bytes32 r2, bytes32 s2) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {MessengerProtocol} from "./IBridge.sol"; interface IRouter { function canSwap() external view returns (uint8); function swap(uint amount, bytes32 token, bytes32 receiveToken, address recipient, uint receiveAmountMin) external; }
// contracts/Messages.sol // SPDX-License-Identifier: Apache 2 pragma solidity ^0.8.18; interface Structs { struct Provider { uint16 chainId; uint16 governanceChainId; bytes32 governanceContract; } struct GuardianSet { address[] keys; uint32 expirationTime; } struct Signature { bytes32 r; bytes32 s; uint8 v; uint8 guardianIndex; } struct VM { uint8 version; uint32 timestamp; uint32 nonce; uint16 emitterChainId; bytes32 emitterAddress; uint64 sequence; uint8 consistencyLevel; bytes payload; uint32 guardianSetIndex; Signature[] signatures; bytes32 hash; } } interface IWormhole is Structs { event LogMessagePublished( address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel ); function publishMessage( uint32 nonce, bytes memory payload, uint8 consistencyLevel ) external payable returns (uint64 sequence); function parseAndVerifyVM( bytes calldata encodedVM ) external view returns (Structs.VM memory vm, bool valid, string memory reason); function verifyVM(Structs.VM memory vm) external view returns (bool valid, string memory reason); function verifySignatures( bytes32 hash, Structs.Signature[] memory signatures, Structs.GuardianSet memory guardianSet ) external pure returns (bool valid, string memory reason); function parseVM(bytes memory encodedVM) external pure returns (Structs.VM memory vm); function getGuardianSet(uint32 index) external view returns (Structs.GuardianSet memory); function getCurrentGuardianSetIndex() external view returns (uint32); function getGuardianSetExpiry() external view returns (uint32); function governanceActionIsConsumed(bytes32 hash) external view returns (bool); function isInitialized(address impl) external view returns (bool); function chainId() external view returns (uint16); function governanceChainId() external view returns (uint16); function governanceContract() external view returns (bytes32); function messageFee() external view returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; library HashUtils { function replaceChainBytes( bytes32 data, uint8 sourceChainId, uint8 destinationChainId ) internal pure returns (bytes32 result) { assembly { mstore(0x00, data) mstore8(0x00, sourceChainId) mstore8(0x01, destinationChainId) result := mload(0x0) } } function hashWithSender(bytes32 message, bytes32 sender) internal pure returns (bytes32 result) { assembly { mstore(0x00, message) mstore(0x20, sender) result := or( and( message, 0xffff000000000000000000000000000000000000000000000000000000000000 // First 2 bytes ), and( keccak256(0x00, 0x40), 0x0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff // Last 30 bytes ) ) } } function hashWithSenderAddress(bytes32 message, address sender) internal pure returns (bytes32 result) { assembly { mstore(0x00, message) mstore(0x20, sender) result := or( and( message, 0xffff000000000000000000000000000000000000000000000000000000000000 // First 2 bytes ), and( keccak256(0x00, 0x40), 0x0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff // Last 30 bytes ) ) } } function hashed(bytes32 message) internal pure returns (bytes32 result) { assembly { mstore(0x00, message) result := keccak256(0x00, 0x20) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IGasOracle} from "./interfaces/IGasOracle.sol"; import {IMessenger} from "./interfaces/IMessenger.sol"; import {GasUsage} from "./GasUsage.sol"; import {HashUtils} from "./libraries/HashUtils.sol"; /** * @dev This contract implements the Allbridge messenger cross-chain communication protocol. */ contract Messenger is Ownable, GasUsage, IMessenger { using HashUtils for bytes32; // current chain ID uint public immutable chainId; // supported destination chain IDs bytes32 public otherChainIds; // the primary account that is responsible for validation that a message has been sent on the source chain address private primaryValidator; // the secondary accounts that are responsible for validation that a message has been sent on the source chain mapping(address => bool) private secondaryValidators; mapping(bytes32 messageHash => uint blockNumber) public override sentMessagesBlock; mapping(bytes32 messageHash => uint isReceived) public override receivedMessages; event MessageSent(bytes32 indexed message); event MessageReceived(bytes32 indexed message); /** * @dev Emitted when the contract receives native gas tokens (e.g. Ether on the Ethereum network). */ event Received(address, uint); /** * @dev Emitted when the mapping of secondary validators is updated. */ event SecondaryValidatorsSet(address[] oldValidators, address[] newValidators); constructor( uint chainId_, bytes32 otherChainIds_, IGasOracle gasOracle_, address primaryValidator_, address[] memory validators ) GasUsage(gasOracle_) { chainId = chainId_; otherChainIds = otherChainIds_; primaryValidator = primaryValidator_; uint length = validators.length; for (uint index; index < length; ) { secondaryValidators[validators[index]] = true; unchecked { index++; } } } /** * @notice Sends a message to another chain. * @dev Emits a {MessageSent} event, which signals to the off-chain messaging service to invoke the `receiveMessage` * function on the destination chain to deliver the message. * * Requirements: * * - the first byte of the message must be the current chain ID. * - the second byte of the message must be the destination chain ID. * - the same message cannot be sent second time. * - messaging fee must be payed. (See `getTransactionCost` of the `GasUsage` contract). * @param message The message to be sent to the destination chain. */ function sendMessage(bytes32 message) external payable override { require(uint8(message[0]) == chainId, "Messenger: wrong chainId"); require(otherChainIds[uint8(message[1])] != 0, "Messenger: wrong destination"); bytes32 messageWithSender = message.hashWithSenderAddress(msg.sender); require(sentMessagesBlock[messageWithSender] == 0, "Messenger: has message"); sentMessagesBlock[messageWithSender] = block.number; require(msg.value >= this.getTransactionCost(uint8(message[1])), "Messenger: not enough fee"); emit MessageSent(messageWithSender); } /** * @notice Delivers a message to the destination chain. * @dev Emits an {MessageReceived} event indicating the message has been delivered. * * Requirements: * * - a valid signature of the primary validator. * - a valid signature of one of the secondary validators. * - the second byte of the message must be the current chain ID. */ function receiveMessage( bytes32 message, uint v1v2, bytes32 r1, bytes32 s1, bytes32 r2, bytes32 s2 ) external override { bytes32 hashedMessage = message.hashed(); require(ecrecover(hashedMessage, uint8(v1v2 >> 8), r1, s1) == primaryValidator, "Messenger: invalid primary"); require(secondaryValidators[ecrecover(hashedMessage, uint8(v1v2), r2, s2)], "Messenger: invalid secondary"); require(uint8(message[1]) == chainId, "Messenger: wrong chainId"); receivedMessages[message] = 1; emit MessageReceived(message); } /** * @dev Allows the admin to withdraw the messaging fee collected in native gas tokens. */ function withdrawGasTokens(uint amount) external onlyOwner { payable(msg.sender).transfer(amount); } /** * @dev Allows the admin to set the primary validator address. */ function setPrimaryValidator(address value) external onlyOwner { primaryValidator = value; } /** * @dev Allows the admin to set the addresses of secondary validators. */ function setSecondaryValidators(address[] memory oldValidators, address[] memory newValidators) external onlyOwner { uint length = oldValidators.length; uint index; for (; index < length; ) { secondaryValidators[oldValidators[index]] = false; unchecked { index++; } } length = newValidators.length; index = 0; for (; index < length; ) { secondaryValidators[newValidators[index]] = true; unchecked { index++; } } emit SecondaryValidatorsSet(oldValidators, newValidators); } /** * @dev Allows the admin to update a list of supported destination chain IDs * @param value Each byte of the `value` parameter represents whether a chain ID with such index is supported * as a valid message destination. */ function setOtherChainIds(bytes32 value) external onlyOwner { otherChainIds = value; } fallback() external payable { revert("Unsupported"); } receive() external payable { emit Received(msg.sender, msg.value); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IGasOracle} from "./interfaces/IGasOracle.sol"; import {Messenger} from "./Messenger.sol"; import {MessengerProtocol} from "./interfaces/IBridge.sol"; import {WormholeMessenger} from "./WormholeMessenger.sol"; /** * @dev This abstract contract provides functions for cross-chain communication and supports different messaging * protocols. */ abstract contract MessengerGateway is Ownable { Messenger private allbridgeMessenger; WormholeMessenger private wormholeMessenger; constructor(Messenger allbridgeMessenger_, WormholeMessenger wormholeMessenger_) { allbridgeMessenger = allbridgeMessenger_; wormholeMessenger = wormholeMessenger_; } /** * @dev Sets the Allbridge Messenger contract address. * @param allbridgeMessenger_ The address of the Messenger contract. */ function setAllbridgeMessenger(Messenger allbridgeMessenger_) external onlyOwner { allbridgeMessenger = allbridgeMessenger_; } /** * @dev Sets the Wormhole Messenger contract address. * @param wormholeMessenger_ The address of the WormholeMessenger contract. */ function setWormholeMessenger(WormholeMessenger wormholeMessenger_) external onlyOwner { wormholeMessenger = wormholeMessenger_; } /** * @notice Get the gas cost of a messaging transaction on another chain in the current chain's native token. * @param chainId The ID of the chain where to send the message. * @param protocol The messenger used to send the message. * @return The calculated gas cost of the messaging transaction in the current chain's native token. */ function getMessageCost(uint chainId, MessengerProtocol protocol) external view returns (uint) { if (protocol == MessengerProtocol.Allbridge) { return allbridgeMessenger.getTransactionCost(chainId); } else if (protocol == MessengerProtocol.Wormhole) { return wormholeMessenger.getTransactionCost(chainId); } return 0; } /** * @notice Get the amount of gas a messaging transaction uses on a given chain. * @param chainId The ID of the chain where to send the message. * @param protocol The messenger used to send the message. * @return The amount of gas a messaging transaction uses. */ function getMessageGasUsage(uint chainId, MessengerProtocol protocol) public view returns (uint) { if (protocol == MessengerProtocol.Allbridge) { return allbridgeMessenger.gasUsage(chainId); } else if (protocol == MessengerProtocol.Wormhole) { return wormholeMessenger.gasUsage(chainId); } return 0; } /** * @notice Checks whether a given message has been received via the specified messenger protocol. * @param message The message to check. * @param protocol The messenger used to send the message. * @return A boolean indicating whether the message has been received. */ function hasReceivedMessage(bytes32 message, MessengerProtocol protocol) external view returns (bool) { if (protocol == MessengerProtocol.Allbridge) { return allbridgeMessenger.receivedMessages(message) != 0; } else if (protocol == MessengerProtocol.Wormhole) { return wormholeMessenger.receivedMessages(message) != 0; } else { revert("Not implemented"); } } /** * @notice Checks whether a given message has been sent. * @param message The message to check. * @return A boolean indicating whether the message has been sent. */ function hasSentMessage(bytes32 message) external view returns (bool) { return allbridgeMessenger.sentMessagesBlock(message) != 0 || wormholeMessenger.sentMessages(message) != 0; } function _sendMessage(bytes32 message, MessengerProtocol protocol) internal returns (uint messageCost) { if (protocol == MessengerProtocol.Allbridge) { messageCost = allbridgeMessenger.getTransactionCost(uint8(message[1])); allbridgeMessenger.sendMessage{value: messageCost}(message); } else if (protocol == MessengerProtocol.Wormhole) { messageCost = wormholeMessenger.getTransactionCost(uint8(message[1])); wormholeMessenger.sendMessage{value: messageCost}(message); } else { revert("Not implemented"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; contract RewardManager is Ownable, ERC20 { using SafeERC20 for ERC20; uint private constant P = 52; uint internal constant BP = 1e4; // Accumulated rewards per share, shifted left by P bits uint public accRewardPerShareP; // Reward token ERC20 public immutable token; // Info of each user reward debt mapping(address user => uint amount) public userRewardDebt; // Admin fee share (in basis points) uint public adminFeeShareBP; // Unclaimed admin fee amount uint public adminFeeAmount; event Deposit(address indexed user, uint amount); event Withdraw(address indexed user, uint amount); event RewardsClaimed(address indexed user, uint amount); constructor(ERC20 token_, string memory lpName, string memory lpSymbol) ERC20(lpName, lpSymbol) { token = token_; // Default admin fee is 20% adminFeeShareBP = BP / 5; } /** * @notice Claims pending rewards for the current staker without updating the stake balance. */ function claimRewards() external { uint userLpAmount = balanceOf(msg.sender); if (userLpAmount > 0) { uint rewards = (userLpAmount * accRewardPerShareP) >> P; uint pending = rewards - userRewardDebt[msg.sender]; if (pending > 0) { userRewardDebt[msg.sender] = rewards; token.safeTransfer(msg.sender, pending); emit RewardsClaimed(msg.sender, pending); } } } /** * @notice Sets the basis points of the admin fee share from rewards. */ function setAdminFeeShare(uint adminFeeShareBP_) external onlyOwner { require(adminFeeShareBP_ <= BP, "RewardManager: too high"); adminFeeShareBP = adminFeeShareBP_; } /** * @notice Allows the admin to claim the collected admin fee. */ function claimAdminFee() external onlyOwner { if (adminFeeAmount > 0) { token.safeTransfer(msg.sender, adminFeeAmount); adminFeeAmount = 0; } } /** * @notice Returns pending rewards for the staker. * @param user The address of the staker. */ function pendingReward(address user) external view returns (uint) { return ((balanceOf(user) * accRewardPerShareP) >> P) - userRewardDebt[user]; } /** * @dev Returns the number of decimals used to get user representation of LP tokens. */ function decimals() public pure override returns (uint8) { return 3; } /** * @dev Adds reward to the pool, splits admin fee share and updates the accumulated rewards per share. */ function _addRewards(uint rewardAmount) internal { if (totalSupply() > 0) { uint adminFeeRewards = (rewardAmount * adminFeeShareBP) / BP; unchecked { rewardAmount -= adminFeeRewards; } accRewardPerShareP += (rewardAmount << P) / totalSupply(); adminFeeAmount += adminFeeRewards; } } /** * @dev Deposits LP amount for the user, updates user reward debt and pays pending rewards. */ function _depositLp(address to, uint lpAmount) internal { uint pending; uint userLpAmount = balanceOf(to); // Gas optimization if (userLpAmount > 0) { pending = ((userLpAmount * accRewardPerShareP) >> P) - userRewardDebt[to]; } userLpAmount += lpAmount; _mint(to, lpAmount); userRewardDebt[to] = (userLpAmount * accRewardPerShareP) >> P; if (pending > 0) { token.safeTransfer(to, pending); emit RewardsClaimed(to, pending); } emit Deposit(to, lpAmount); } /** * @dev Withdraws LP amount for the user, updates user reward debt and pays out pending rewards. */ function _withdrawLp(address from, uint lpAmount) internal { uint userLpAmount = balanceOf(from); // Gas optimization require(userLpAmount >= lpAmount, "RewardManager: not enough amount"); uint pending; if (userLpAmount > 0) { pending = ((userLpAmount * accRewardPerShareP) >> P) - userRewardDebt[from]; } userLpAmount -= lpAmount; _burn(from, lpAmount); userRewardDebt[from] = (userLpAmount * accRewardPerShareP) >> P; if (pending > 0) { token.safeTransfer(from, pending); emit RewardsClaimed(from, pending); } emit Withdraw(from, lpAmount); } function _transfer(address, address, uint) internal pure override { revert("Unsupported"); } function _approve(address, address, uint) internal pure override { revert("Unsupported"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IRouter} from "./interfaces/IRouter.sol"; import {MessengerProtocol} from "./interfaces/IBridge.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {Pool} from "./Pool.sol"; abstract contract Router is Ownable, IRouter { using SafeERC20 for ERC20; uint private immutable chainPrecision; uint internal constant ORACLE_PRECISION = 18; mapping(bytes32 tokenId => Pool) public pools; // precomputed values to divide by to change the precision from the Gas Oracle precision to the token precision mapping(address tokenAddress => uint scalingFactor) internal fromGasOracleScalingFactor; // precomputed values of the scaling factor required for paying the bridging fee with stable tokens mapping(address tokenAddress => uint scalingFactor) internal bridgingFeeConversionScalingFactor; // can restrict swap operations address private stopAuthority; /** * @dev The rebalancer is an account responsible for balancing the liquidity pools. It ensures that the pool is * balanced by executing zero-fee swaps when the pool is imbalanced. * * Gas optimization: both the 'rebalancer' and 'canSwap' fields are used in the 'swap' and 'swapAndBridge' * functions and can occupy the same slot. */ address private rebalancer; uint8 public override canSwap = 1; /** * @dev Emitted during the on-chain swap of tokens. */ event Swapped( address sender, address recipient, bytes32 sendToken, bytes32 receiveToken, uint sendAmount, uint receiveAmount ); constructor(uint chainPrecision_) { chainPrecision = chainPrecision_; stopAuthority = owner(); } /** * @dev Modifier to make a function callable only when the swap is allowed. */ modifier whenCanSwap() { require(canSwap == 1, "Router: swap prohibited"); _; } /** * @dev Throws if called by any account other than the stopAuthority. */ modifier onlyStopAuthority() { require(stopAuthority == msg.sender, "Router: is not stopAuthority"); _; } /** * @notice Swaps a given pair of tokens on the same blockchain. * @param amount The amount of tokens to be swapped. * @param token The token to be swapped. * @param receiveToken The token to receive in exchange for the swapped token. * @param recipient The address to receive the tokens. * @param receiveAmountMin The minimum amount of tokens required to receive during the swap. */ function swap( uint amount, bytes32 token, bytes32 receiveToken, address recipient, uint receiveAmountMin ) external override whenCanSwap { uint vUsdAmount = _sendAndSwapToVUsd(token, msg.sender, amount); uint receivedAmount = _receiveAndSwapFromVUsd(receiveToken, recipient, vUsdAmount, receiveAmountMin); emit Swapped(msg.sender, recipient, token, receiveToken, amount, receivedAmount); } /** * @notice Allows the admin to add new supported liquidity pools. * @dev Adds the address of the `Pool` contract to the list of supported liquidity pools. * @param pool The address of the `Pool` contract. * @param token The address of the token in the liquidity pool. */ function addPool(Pool pool, bytes32 token) external onlyOwner { pools[token] = pool; address tokenAddress = address(uint160(uint(token))); uint tokenDecimals = ERC20(tokenAddress).decimals(); bridgingFeeConversionScalingFactor[tokenAddress] = 10 ** (ORACLE_PRECISION - tokenDecimals + chainPrecision); fromGasOracleScalingFactor[tokenAddress] = 10 ** (ORACLE_PRECISION - tokenDecimals); } /** * @dev Switches off the possibility to make swaps. */ function stopSwap() external onlyStopAuthority { canSwap = 0; } /** * @dev Switches on the possibility to make swaps. */ function startSwap() external onlyOwner { canSwap = 1; } /** * @dev Allows the admin to set the address of the stopAuthority. */ function setStopAuthority(address stopAuthority_) external onlyOwner { stopAuthority = stopAuthority_; } /** * @dev Allows the admin to set the address of the rebalancer. */ function setRebalancer(address rebalancer_) external onlyOwner { rebalancer = rebalancer_; } function _receiveAndSwapFromVUsd( bytes32 token, address recipient, uint vUsdAmount, uint receiveAmountMin ) internal returns (uint) { Pool tokenPool = pools[token]; require(address(tokenPool) != address(0), "Router: no receive pool"); return tokenPool.swapFromVUsd(recipient, vUsdAmount, receiveAmountMin, recipient == rebalancer); } function _sendAndSwapToVUsd(bytes32 token, address user, uint amount) internal virtual returns (uint) { Pool pool = pools[token]; require(address(pool) != address(0), "Router: no pool"); ERC20(address(uint160(uint(token)))).safeTransferFrom(user, address(pool), amount); return pool.swapToVUsd(user, amount, user == rebalancer); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {IBridge, MessengerProtocol} from "../interfaces/IBridge.sol"; import {Router} from "../Router.sol"; contract TestBridgeForSwap is IBridge, Router { uint public chainId; mapping(bytes32 messageHash => uint isProcessed) public override processedMessages; mapping(bytes32 messageHash => uint isSent) public override sentMessages; // Info about bridges on other chains mapping(uint chainId => bytes32 bridgeAddress) public override otherBridges; // Info about tokens on other chains mapping(uint chainId => mapping(bytes32 tokenAddress => bool isSupported)) public override otherBridgeTokens; event vUsdSent(uint amount); constructor() Router(18) {} function swapAndBridge( bytes32 token, uint amount, bytes32 recipient, uint destinationChainId, bytes32 receiveToken, uint nonce, MessengerProtocol messenger, uint feeTokenAmount ) external payable override {} function receiveTokens( uint amount, bytes32, uint, bytes32 receiveToken, uint, MessengerProtocol, uint receiveAmountMin ) external payable override {} function withdrawGasTokens(uint amount) external override onlyOwner {} function registerBridge(uint chainId_, bytes32 bridgeAddress_) external override onlyOwner {} function addBridgeToken(uint chainId_, bytes32 tokenAddress_) external override onlyOwner {} function removeBridgeToken(uint chainId_, bytes32 tokenAddress_) external override onlyOwner {} function getBridgingCostInTokens( uint, MessengerProtocol, address ) external pure override returns (uint) { return 0; } function hashMessage( uint, bytes32, uint, uint, bytes32, uint, MessengerProtocol ) external pure override returns (bytes32) { return 0; } function _sendAndSwapToVUsd(bytes32 token, address user, uint amount) internal override returns (uint) { uint vUsdAmount = super._sendAndSwapToVUsd(token, user, amount); emit vUsdSent(vUsdAmount); return vUsdAmount; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Pool} from "../Pool.sol"; import {RewardManager} from "../RewardManager.sol"; contract TestPool is Pool { constructor( address router_, uint a_, ERC20 token_, uint16 feeShareBP_, uint balanceRatioMinBP_ ) Pool(router_, a_, token_, feeShareBP_, balanceRatioMinBP_, "LP", "LP") {} function setVUsdBalance(uint vUsdBalance_) public { vUsdBalance = vUsdBalance_; } function setTokenBalance(uint tokenBalance_) public { tokenBalance = tokenBalance_; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {RewardManager} from "../RewardManager.sol"; contract TestPoolForRewards is RewardManager { // solhint-disable-next-line no-empty-blocks constructor(ERC20 token) RewardManager(token, "LP", "LP") {} function deposit(uint amount) external { _depositLp(msg.sender, amount); } function withdraw(uint amount) external { _withdrawLp(msg.sender, amount); } function addRewards(uint amount) external { _addRewards(amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IGasOracle} from "./interfaces/IGasOracle.sol"; import {IMessenger} from "./interfaces/IMessenger.sol"; import {IWormhole} from "./interfaces/IWormhole.sol"; import {GasUsage} from "./GasUsage.sol"; import {GasOracle} from "./GasOracle.sol"; import {HashUtils} from "./libraries/HashUtils.sol"; contract WormholeMessenger is Ownable, GasUsage { using HashUtils for bytes32; IWormhole private immutable wormhole; uint public immutable chainId; bytes32 public otherChainIds; uint32 private nonce; uint8 private commitmentLevel; mapping(uint16 chainId => bytes32 wormholeMessengerAddress) private otherWormholeMessengers; mapping(bytes32 messageHash => uint isReceived) public receivedMessages; mapping(bytes32 messageHash => uint isSent) public sentMessages; event MessageSent(bytes32 indexed message, uint64 sequence); event MessageReceived(bytes32 indexed message, uint64 sequence); event Received(address, uint); constructor( uint chainId_, bytes32 otherChainIds_, IWormhole wormhole_, uint8 commitmentLevel_, IGasOracle gasOracle_ ) GasUsage(gasOracle_) { chainId = chainId_; otherChainIds = otherChainIds_; wormhole = wormhole_; commitmentLevel = commitmentLevel_; } function sendMessage(bytes32 message) external payable { require(uint8(message[0]) == chainId, "WormholeMessenger: wrong chainId"); require(otherChainIds[uint8(message[1])] != 0, "Messenger: wrong destination"); bytes32 messageWithSender = message.hashWithSenderAddress(msg.sender); uint32 nonce_ = nonce; uint64 sequence = wormhole.publishMessage(nonce_, abi.encodePacked(messageWithSender), commitmentLevel); unchecked { nonce = nonce_ + 1; } require(sentMessages[messageWithSender] == 0, "WormholeMessenger: has message"); sentMessages[messageWithSender] = 1; emit MessageSent(messageWithSender, sequence); } function receiveMessage(bytes memory encodedMsg) external { (IWormhole.VM memory vm, bool valid, string memory reason) = wormhole.parseAndVerifyVM(encodedMsg); require(valid, reason); require(vm.payload.length == 32, "WormholeMessenger: wrong length"); bytes32 messageWithSender = bytes32(vm.payload); require(uint8(messageWithSender[1]) == chainId, "WormholeMessenger: wrong chainId"); require(otherWormholeMessengers[vm.emitterChainId] == vm.emitterAddress, "WormholeMessenger: wrong emitter"); receivedMessages[messageWithSender] = 1; emit MessageReceived(messageWithSender, vm.sequence); } function setCommitmentLevel(uint8 value) external onlyOwner { commitmentLevel = value; } function setOtherChainIds(bytes32 value) external onlyOwner { otherChainIds = value; } function registerWormholeMessenger(uint16 chainId_, bytes32 address_) external onlyOwner { otherWormholeMessengers[chainId_] = address_; } function withdrawGasTokens(uint amount) external onlyOwner { payable(msg.sender).transfer(amount); } fallback() external payable { revert("Unsupported"); } receive() external payable { emit Received(msg.sender, msg.value); } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"router_","type":"address"},{"internalType":"uint256","name":"a_","type":"uint256"},{"internalType":"contract ERC20","name":"token_","type":"address"},{"internalType":"uint16","name":"feeShareBP_","type":"uint16"},{"internalType":"uint256","name":"balanceRatioMinBP_","type":"uint256"},{"internalType":"string","name":"lpName","type":"string"},{"internalType":"string","name":"lpSymbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"vUsdAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"SwappedFromVUsd","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vUsdAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"SwappedToVUsd","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"a","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accRewardPerShareP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adjustTotalLpAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"adminFeeAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminFeeShareBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceRatioMinBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimAdminFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"d","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeShareBP","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"getY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"pendingReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"adminFeeShareBP_","type":"uint256"}],"name":"setAdminFeeShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"balanceRatioMinBP_","type":"uint256"}],"name":"setBalanceRatioMinBP","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"feeShareBP_","type":"uint16"}],"name":"setFeeShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"router_","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"stopAuthority_","type":"address"}],"name":"setStopAuthority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"receiveAmountMin","type":"uint256"},{"internalType":"bool","name":"zeroFee","type":"bool"}],"name":"swapFromVUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"zeroFee","type":"bool"}],"name":"swapToVUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userRewardDebt","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vUsdBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountLp","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
610100604052600160115560016012553480156200001c57600080fd5b5060405162003666380380620036668339810160408190526200003f9162000302565b84828281816200004f33620001d4565b60046200005d838262000455565b5060056200006c828262000455565b5050506001600160a01b0383166080526200008b600561271062000537565b60085550505060a0869052600a805462010000600160b01b031916620100006001600160a01b038a1602179055620000cb6000546001600160a01b031690565b601080546001600160a01b0319166001600160a01b03928316179055600a805461ffff191661ffff8716179055600d8490556040805163313ce56760e01b8152905160009288169163313ce5679160048083019260209291908290030181865afa1580156200013e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200016491906200055a565b60ff169050600381116200017a57600062000194565b6200018760038262000586565b6200019490600a6200069f565b60c05260038110620001a8576000620001c2565b620001b581600362000586565b620001c290600a6200069f565b60e05250620006ad9650505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200023a57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200026557600080fd5b81516001600160401b03808211156200028257620002826200023d565b604051601f8301601f19908116603f01168101908282118183101715620002ad57620002ad6200023d565b81604052838152602092508683858801011115620002ca57600080fd5b600091505b83821015620002ee5785820183015181830184015290820190620002cf565b600093810190920192909252949350505050565b600080600080600080600060e0888a0312156200031e57600080fd5b87516200032b8162000224565b602089015160408a01519198509650620003458162000224565b606089015190955061ffff811681146200035e57600080fd5b608089015160a08a015191955093506001600160401b03808211156200038357600080fd5b620003918b838c0162000253565b935060c08a0151915080821115620003a857600080fd5b50620003b78a828b0162000253565b91505092959891949750929550565b600181811c90821680620003db57607f821691505b602082108103620003fc57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200045057600081815260208120601f850160051c810160208610156200042b5750805b601f850160051c820191505b818110156200044c5782815560010162000437565b5050505b505050565b81516001600160401b038111156200047157620004716200023d565b6200048981620004828454620003c6565b8462000402565b602080601f831160018114620004c15760008415620004a85750858301515b600019600386901b1c1916600185901b1785556200044c565b600085815260208120601f198616915b82811015620004f257888601518255948401946001909101908401620004d1565b5085821015620005115787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b6000826200055557634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156200056d57600080fd5b815160ff811681146200057f57600080fd5b9392505050565b818103818111156200059c576200059c62000521565b92915050565b600181815b80851115620005e3578160001904821115620005c757620005c762000521565b80851615620005d557918102915b93841c9390800290620005a7565b509250929050565b600082620005fc575060016200059c565b816200060b575060006200059c565b81600181146200062457600281146200062f576200064f565b60019150506200059c565b60ff84111562000643576200064362000521565b50506001821b6200059c565b5060208310610133831016604e8410600b841016171562000674575081810a6200059c565b620006808383620005a2565b806000190482111562000697576200069762000521565b029392505050565b60006200057f8383620005eb565b60805160a05160c05160e051612eec6200077a60003960008181611ecb01528181611ef401528181611f710152611f9a015260008181611e7b01528181611ea401528181611f210152611f4a0152600081816103fa0152818161165a01528181611769015281816117bb0152818161180a0152818161188f015261230801526000818161092c01528181610bbb01528181610f2d01528181610f72015281816113450152818161144f01528181611aac01528181611ced0152818161223e01526124f40152612eec6000f3fe6080604052600436106103175760003560e01c806379df4fa21161019a578063a9059cbb116100e1578063e78a58751161008a578063f40f0f5211610064578063f40f0f52146108d4578063f887ea40146108f4578063fc0c546a1461091a57610357565b8063e78a587514610889578063e99fee3e1461089f578063f2fde38b146108b457610357565b8063c0d78655116100bb578063c0d7865514610803578063c1c46dbe14610823578063dd62ed3e1461084357610357565b8063a9059cbb146103b8578063b51459fe146107cd578063b6b55f25146107e357610357565b80638da5cb5b1161014357806398d5fdca1161011d57806398d5fdca146107825780639e1a4d1914610797578063a457c2d7146107ad57610357565b80638da5cb5b1461072657806390ed6bf41461075857806395d89b411461076d57610357565b80638427a581116101745780638427a581146106db578063845a4697146106f05780638a054ac21461071057610357565b806379df4fa2146106825780637a23032c146106975780637f6a92ed146106ad57610357565b806335c24a881161025e57806352fb8b031161020757806370a08231116101e157806370a0823114610621578063715018a61461065757806375172a8b1461066c57610357565b806352fb8b03146105e15780635860638d146105f757806358ba94d71461060c57610357565b8063488cb84111610238578063488cb8411461057e5780634927b44c146105945780634bf6f9e7146105b457610357565b806335c24a8814610533578063372500ab14610549578063395093511461055e57610357565b806328fdb481116102c05780632e1a7d4d1161029a5780632e1a7d4d146104d7578063313ce567146104f75780633536a1dc1461051357610357565b806328fdb481146104755780632d46f63e146104955780632d8fe99a146104b557610357565b80630ec33022116102f15780630ec330221461042a57806318160ddd1461044057806323b872dd1461045557610357565b806306fdde031461038d578063095ea7b3146103b85780630dbe671f146103e857610357565b366103575760405162461bcd60e51b815260206004820152600b60248201526a155b9cdd5c1c1bdc9d195960aa1b60448201526064015b60405180910390fd5b60405162461bcd60e51b815260206004820152600b60248201526a155b9cdd5c1c1bdc9d195960aa1b604482015260640161034e565b34801561039957600080fd5b506103a261094e565b6040516103af9190612b31565b60405180910390f35b3480156103c457600080fd5b506103d86103d3366004612b80565b6109e0565b60405190151581526020016103af565b3480156103f457600080fd5b5061041c7f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016103af565b34801561043657600080fd5b5061041c600c5481565b34801561044c57600080fd5b5060035461041c565b34801561046157600080fd5b506103d8610470366004612baa565b6109fa565b34801561048157600080fd5b5061041c610490366004612bf4565b610a20565b3480156104a157600080fd5b5061041c6104b0366004612c34565b610d1d565b3480156104c157600080fd5b506104d56104d0366004612c7c565b6110dd565b005b3480156104e357600080fd5b506104d56104f2366004612c7c565b61113c565b34801561050357600080fd5b50604051600381526020016103af565b34801561051f57600080fd5b506104d561052e366004612c95565b611371565b34801561053f57600080fd5b5061041c600d5481565b34801561055557600080fd5b506104d56113e7565b34801561056a57600080fd5b506103d8610579366004612b80565b6114b9565b34801561058a57600080fd5b5061041c60085481565b3480156105a057600080fd5b506104d56105af366004612cb9565b6114f8565b3480156105c057600080fd5b5061041c6105cf366004612cb9565b60076020526000908152604090205481565b3480156105ed57600080fd5b5061041c60065481565b34801561060357600080fd5b506104d561152f565b34801561061857600080fd5b506104d5611590565b34801561062d57600080fd5b5061041c61063c366004612cb9565b6001600160a01b031660009081526001602052604090205490565b34801561066357600080fd5b506104d56115f1565b34801561067857600080fd5b5061041c600e5481565b34801561068e57600080fd5b506104d5611605565b3480156106a357600080fd5b5061041c60095481565b3480156106b957600080fd5b50600a546106c89061ffff1681565b60405161ffff90911681526020016103af565b3480156106e757600080fd5b506104d5611614565b3480156106fc57600080fd5b5061041c61070b366004612c7c565b611652565b34801561071c57600080fd5b5061041c600f5481565b34801561073257600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016103af565b34801561076457600080fd5b506104d561173f565b34801561077957600080fd5b506103a261174e565b34801561078e57600080fd5b5061041c61175d565b3480156107a357600080fd5b5061041c600b5481565b3480156107b957600080fd5b506103d86107c8366004612b80565b611938565b3480156107d957600080fd5b5061041c60125481565b3480156107ef57600080fd5b506104d56107fe366004612c7c565b6119ed565b34801561080f57600080fd5b506104d561081e366004612cb9565b611c25565b34801561082f57600080fd5b506104d561083e366004612c7c565b611c6d565b34801561084f57600080fd5b5061041c61085e366004612cd4565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b34801561089557600080fd5b5061041c60115481565b3480156108ab57600080fd5b506104d5611ccc565b3480156108c057600080fd5b506104d56108cf366004612cb9565b611d1c565b3480156108e057600080fd5b5061041c6108ef366004612cb9565b611da9565b34801561090057600080fd5b50600a54610740906201000090046001600160a01b031681565b34801561092657600080fd5b506107407f000000000000000000000000000000000000000000000000000000000000000081565b60606004805461095d90612d07565b80601f016020809104026020016040519081016040528092919081815260200182805461098990612d07565b80156109d65780601f106109ab576101008083540402835291602001916109d6565b820191906000526020600020905b8154815290600101906020018083116109b957829003601f168201915b5050505050905090565b6000336109ee818585610357565b60019150505b92915050565b600033610a08858285611deb565b610a13858585610357565b60019150505b9392505050565b600a546000906201000090046001600160a01b03163314610a835760405162461bcd60e51b815260206004820152601360248201527f506f6f6c3a206973206e6f7420726f7574657200000000000000000000000000604482015260640161034e565b6000808415610ba85783610ab357600a5461271090610aa69061ffff1687612d57565b610ab09190612d84565b90505b6000610ac7610ac28388612d98565b611e77565b9050610ad281611f1d565b610adc9087612d98565b915080600b6000828254610af09190612dab565b9250508190555080600e6000828254610b099190612dab565b9091555050600b5460405163845a469760e01b8152600091309163845a469791610b399160040190815260200190565b602060405180830381865afa158015610b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7a9190612dbe565b905080600c541115610b975780600c54610b949190612d98565b93505b600c819055610ba583611fbf565b50505b604080516001600160a01b0380891682527f000000000000000000000000000000000000000000000000000000000000000016602082015290810186905260608101839052608081018290527fa930da1d3f27a25892307dd59cec52dd9b881661a0f20364757f83a0da2f68739060a00160405180910390a1509050600c54600b541115610ca357600d54600b54612710600c54610c469190612d57565b610c509190612d84565b1015610c9e5760405162461bcd60e51b815260206004820152601660248201527f506f6f6c3a206c6f7720765553442062616c616e636500000000000000000000604482015260640161034e565b610a19565b600c54600b541015610a1957600d54600c54612710600b54610cc59190612d57565b610ccf9190612d84565b1015610a195760405162461bcd60e51b815260206004820152601760248201527f506f6f6c3a206c6f7720746f6b656e2062616c616e6365000000000000000000604482015260640161034e565b600a546000906201000090046001600160a01b03163314610d805760405162461bcd60e51b815260206004820152601360248201527f506f6f6c3a206973206e6f7420726f7574657200000000000000000000000000604482015260640161034e565b600080808615610f5f5786600c6000828254610d9c9190612dab565b9091555050600c5460405163845a469760e01b8152600091309163845a469791610dcc9160040190815260200190565b602060405180830381865afa158015610de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0d9190612dbe565b905080600b541115610e355780600b54610e279190612d98565b9350610e3284611f1d565b92505b600e54841115610e875760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a207265736572766573000000000000000000000000000000000000604482015260640161034e565b83600e6000828254610e999190612d98565b90915550869050610ec657600a5461271090610eb99061ffff1685612d57565b610ec39190612d84565b91505b600b819055918190039186831015610f205760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a20736c697070616765000000000000000000000000000000000000604482015260640161034e565b610f546001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168a8561203e565b610f5d82611fbf565b505b604080516001600160a01b03808b1682527f000000000000000000000000000000000000000000000000000000000000000016602082015290810188905260608101839052608081018290527ffc1df7b9ba72a13350b8a4e0f094e232eebded9edd179950e74a852a0f4051129060a00160405180910390a150915050600c54600b54111561105b57600d54600b54612710600c54610ffe9190612d57565b6110089190612d84565b10156110565760405162461bcd60e51b815260206004820152601660248201527f506f6f6c3a206c6f7720765553442062616c616e636500000000000000000000604482015260640161034e565b6110d5565b600c54600b5410156110d557600d54600c54612710600b5461107d9190612d57565b6110879190612d84565b10156110d55760405162461bcd60e51b815260206004820152601760248201527f506f6f6c3a206c6f7720746f6b656e2062616c616e6365000000000000000000604482015260640161034e565b949350505050565b6110e56120e7565b6127108111156111375760405162461bcd60e51b815260206004820152601760248201527f5265776172644d616e616765723a20746f6f2068696768000000000000000000604482015260640161034e565b600855565b60125460011461118e5760405162461bcd60e51b815260206004820152601960248201527f506f6f6c3a2077697468647261772070726f6869626974656400000000000000604482015260640161034e565b600f5461119b3383612141565b6000600c54600b546111ad9190612dab565b905080600b54846111be9190612d57565b6111c89190612d84565b600b60008282546111d99190612d98565b9091555050600c5481906111ed9085612d57565b6111f79190612d84565b600c60008282546112089190612d98565b9091555050600c54600b54829161121e91612dab565b1061126b5760405162461bcd60e51b815260206004820152601260248201527f506f6f6c3a207a65726f206368616e6765730000000000000000000000000000604482015260640161034e565b600e548311156112bd5760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a207265736572766573000000000000000000000000000000000000604482015260640161034e565b82600e60008282546112cf9190612d98565b909155506112dd90506122f2565b81600f541061132e5760405162461bcd60e51b815260206004820152601460248201527f506f6f6c3a207a65726f2044206368616e676573000000000000000000000000604482015260640161034e565b61136c3361133b85611f1d565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016919061203e565b505050565b6113796120e7565b6127108161ffff1611156113cf5760405162461bcd60e51b815260206004820152600f60248201527f506f6f6c3a20746f6f206c617267650000000000000000000000000000000000604482015260640161034e565b600a805461ffff191661ffff92909216919091179055565b3360009081526001602052604090205480156114b657600060346006548361140f9190612d57565b336000908152600760205260408120549190921c925061142f9083612d98565b9050801561136c5733600081815260076020526040902083905561147e907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316908361203e565b60405181815233907ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe9060200160405180910390a250505b50565b3360008181526002602090815260408083206001600160a01b03871684529091528120549091906109ee90829086906114f3908790612dab565b610357565b6115006120e7565b6010805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6010546001600160a01b031633146115895760405162461bcd60e51b815260206004820152601a60248201527f506f6f6c3a206973206e6f742073746f70417574686f72697479000000000000604482015260640161034e565b6000601255565b6010546001600160a01b031633146115ea5760405162461bcd60e51b815260206004820152601a60248201527f506f6f6c3a206973206e6f742073746f70417574686f72697479000000000000604482015260640161034e565b6000601155565b6115f96120e7565b61160360006123ec565b565b61160d6120e7565b6001601155565b61161c6120e7565b600354600f5411156116035761160361163d6000546001600160a01b031690565b600354600f5461164d9190612d98565b612449565b600f546000907f0000000000000000000000000000000000000000000000000000000000000000600281901b9060031b838361168e8782612dd7565b6116989085612df7565b6116a29190612dd7565b905060006116b08280612df7565b6116ba9088612d57565b85806116c68188612d57565b6116d09190612d57565b6116da9190612d57565b6116e49190612dab565b6116ee9088612d57565b90506116fa8784612d57565b61171f611707848a612df7565b6117108461259a565b61171a9190612e27565b6125fb565b6117299190612d84565b611734906001612dab565b979650505050505050565b6117476120e7565b6001601255565b60606005805461095d90612d07565b600b54600f54600091907f000000000000000000000000000000000000000000000000000000000000000060031b9083906117988180612d57565b6117a29190612d57565b600f549091506000906117b58582612dd7565b6117e2907f000000000000000000000000000000000000000000000000000000000000000060021b612df7565b6117ec9190612dd7565b905060006117fa8280612df7565b6118049086612d57565b611831847f000000000000000000000000000000000000000000000000000000000000000060021b612d57565b61183b9190612dab565b6118459086612d57565b9050600085866001600f54901b61185c9190612d57565b6118669190612d57565b86806118728189612d57565b61187c9190612d57565b6118869190612d57565b8788600f5460037f0000000000000000000000000000000000000000000000000000000000000000901b6118ba9190612d57565b6118c49190612d57565b6118ce9190612d57565b6118d89087612e27565b6118e29190612dd7565b6118ec9190612dd7565b905061192d6118fa8361259a565b61190890600289901b612d57565b61191483612710612df7565b61191e9190612e4f565b61171a9061271060011d612e27565b965050505050505090565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909190838110156119d55760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161034e565b6119e28286868403610357565b506001949350505050565b601154600114611a3f5760405162461bcd60e51b815260206004820152601860248201527f506f6f6c3a206465706f7369742070726f686962697465640000000000000000604482015260640161034e565b600f546000611a4d83611e77565b905060008111611a9f5760405162461bcd60e51b815260206004820152601060248201527f506f6f6c3a20746f6f206c6974746c6500000000000000000000000000000000604482015260640161034e565b611ad46001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308661264d565b80600e6000828254611ae69190612dab565b9091555050600c54600b54600091611afd91612dab565b9050821580611b0a575080155b15611b4f576000600183901c905080600b6000828254611b2a9190612dab565b9250508190555080600c6000828254611b439190612dab565b90915550611bae915050565b80600b5483611b5e9190612d57565b611b689190612d84565b600b6000828254611b799190612dab565b9091555050600c548190611b8d9084612d57565b611b979190612d84565b600c6000828254611ba89190612dab565b90915550505b611bb66122f2565b611bc83384600f5461164d9190612d98565b65010000000000600b5410611c1f5760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a20746f6f206d756368000000000000000000000000000000000000604482015260640161034e565b50505050565b611c2d6120e7565b600a80546001600160a01b0390921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b611c756120e7565b612710811115611cc75760405162461bcd60e51b815260206004820152600f60248201527f506f6f6c3a20746f6f206c617267650000000000000000000000000000000000604482015260640161034e565b600d55565b611cd46120e7565b6009541561160357600954611d15906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690339061203e565b6000600955565b611d246120e7565b6001600160a01b038116611da05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161034e565b6114b6816123ec565b6001600160a01b0381166000908152600760209081526040808320546006546001909352908320549091603491611de09190612d57565b6109f492911c612d98565b6001600160a01b038381166000908152600260209081526040808320938616835292905220546000198114611c1f5781811015611e6a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161034e565b611c1f8484848403610357565b60007f000000000000000000000000000000000000000000000000000000000000000015611ec9576109f47f000000000000000000000000000000000000000000000000000000000000000083612d84565b7f000000000000000000000000000000000000000000000000000000000000000015611f19576109f47f000000000000000000000000000000000000000000000000000000000000000083612d57565b5090565b60007f000000000000000000000000000000000000000000000000000000000000000015611f6f576109f47f000000000000000000000000000000000000000000000000000000000000000083612d57565b7f000000000000000000000000000000000000000000000000000000000000000015611f19576109f47f000000000000000000000000000000000000000000000000000000000000000083612d84565b6000611fca60035490565b11156114b657600061271060085483611fe39190612d57565b611fed9190612d84565b90508082039150611ffd60035490565b61200b90603484901b612d84565b6006600082825461201c9190612dab565b9250508190555080600960008282546120359190612dab565b90915550505050565b6040516001600160a01b03831660248201526044810182905261136c9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261269e565b6000546001600160a01b031633146116035760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161034e565b6001600160a01b038216600090815260016020526040902054818110156121aa5760405162461bcd60e51b815260206004820181905260248201527f5265776172644d616e616765723a206e6f7420656e6f75676820616d6f756e74604482015260640161034e565b600081156121e9576001600160a01b0384166000908152600760205260409020546006546034906121db9085612d57565b6121e692911c612d98565b90505b6121f38383612d98565b91506121ff8484612783565b60346006548361220f9190612d57565b6001600160a01b0386166000908152600760205260409020911c905580156122a9576122656001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858361203e565b836001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe826040516122a091815260200190565b60405180910390a25b836001600160a01b03167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364846040516122e491815260200190565b60405180910390a250505050565b600b54600c5460006123048284612d57565b90507f000000000000000000000000000000000000000000000000000000000000000060006123338486612dab565b61233d8484612d57565b6123479190612d57565b90506000600361235c6001600286901b612d98565b6123669086612d57565b6123709190612d84565b905060006123a5826123828180612d57565b61238c9190612d57565b6123968580612d57565b6123a09190612dab565b61259a565b905060006123b48285016128ee565b9050838211156123d0576123c98483036128ee565b90036123dd565b6123db8285036128ee565b015b60011b600f5550505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038216600090815260016020526040812054801561249f576001600160a01b0384166000908152600760205260409020546006546034906124919084612d57565b61249c92911c612d98565b91505b6124a98382612dab565b90506124b58484612939565b6034600654826124c59190612d57565b6001600160a01b0386166000908152600760205260409020911c9055811561255f5761251b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461203e565b836001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8360405161255691815260200190565b60405180910390a25b836001600160a01b03167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c846040516122e491815260200190565b600081156125f357600182811c8101906000908285816125bc576125bc612d6e565b048301901c90505b808211156125ec5780915060018285816125e0576125e0612d6e565b048301901c90506125c4565b5092915050565b506000919050565b600080821215611f195760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f736974697665604482015260640161034e565b6040516001600160a01b0380851660248301528316604482015260648101829052611c1f9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612083565b60006126f3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129fa9092919063ffffffff16565b80519091501561136c57808060200190518101906127119190612e7d565b61136c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161034e565b6001600160a01b0382166127ff5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161034e565b6001600160a01b0382166000908152600160205260409020548181101561288e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840161034e565b6001600160a01b03831660008181526001602090815260408083208686039055600380548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b600080600160ff1b5b80156125ec57600191821b918281018302600302018082868161291c5761291c612d6e565b041061293057808202850394506001830192505b5060031c6128f7565b6001600160a01b03821661298f5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161034e565b80600360008282546129a19190612dab565b90915550506001600160a01b0382166000818152600160209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60606110d5848460008585600080866001600160a01b03168587604051612a219190612e9a565b60006040518083038185875af1925050503d8060008114612a5e576040519150601f19603f3d011682016040523d82523d6000602084013e612a63565b606091505b50915091506117348783838760608315612ade578251600003612ad7576001600160a01b0385163b612ad75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161034e565b50816110d5565b6110d58383815115612af35781518083602001fd5b8060405162461bcd60e51b815260040161034e9190612b31565b60005b83811015612b28578181015183820152602001612b10565b50506000910152565b6020815260008251806020840152612b50816040850160208701612b0d565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114612b7b57600080fd5b919050565b60008060408385031215612b9357600080fd5b612b9c83612b64565b946020939093013593505050565b600080600060608486031215612bbf57600080fd5b612bc884612b64565b9250612bd660208501612b64565b9150604084013590509250925092565b80151581146114b657600080fd5b600080600060608486031215612c0957600080fd5b612c1284612b64565b9250602084013591506040840135612c2981612be6565b809150509250925092565b60008060008060808587031215612c4a57600080fd5b612c5385612b64565b935060208501359250604085013591506060850135612c7181612be6565b939692955090935050565b600060208284031215612c8e57600080fd5b5035919050565b600060208284031215612ca757600080fd5b813561ffff81168114610a1957600080fd5b600060208284031215612ccb57600080fd5b610a1982612b64565b60008060408385031215612ce757600080fd5b612cf083612b64565b9150612cfe60208401612b64565b90509250929050565b600181811c90821680612d1b57607f821691505b602082108103612d3b57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176109f4576109f4612d41565b634e487b7160e01b600052601260045260246000fd5b600082612d9357612d93612d6e565b500490565b818103818111156109f4576109f4612d41565b808201808211156109f4576109f4612d41565b600060208284031215612dd057600080fd5b5051919050565b81810360008312801583831316838312821617156125ec576125ec612d41565b80820260008212600160ff1b84141615612e1357612e13612d41565b81810583148215176109f4576109f4612d41565b8082018281126000831280158216821582161715612e4757612e47612d41565b505092915050565b600082612e5e57612e5e612d6e565b600160ff1b821460001984141615612e7857612e78612d41565b500590565b600060208284031215612e8f57600080fd5b8151610a1981612be6565b60008251612eac818460208701612b0d565b919091019291505056fea2646970667358221220cf8bbc8d773f3a9e8c446559f4074b1091e3753e4d731f648de781ae83d19e6864736f6c63430008120033000000000000000000000000609c690e8f7d68a59885c9132e812eebdaaf0c9e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000f00000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000c416c6c627269646765204c50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074c502d5553444300000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106103175760003560e01c806379df4fa21161019a578063a9059cbb116100e1578063e78a58751161008a578063f40f0f5211610064578063f40f0f52146108d4578063f887ea40146108f4578063fc0c546a1461091a57610357565b8063e78a587514610889578063e99fee3e1461089f578063f2fde38b146108b457610357565b8063c0d78655116100bb578063c0d7865514610803578063c1c46dbe14610823578063dd62ed3e1461084357610357565b8063a9059cbb146103b8578063b51459fe146107cd578063b6b55f25146107e357610357565b80638da5cb5b1161014357806398d5fdca1161011d57806398d5fdca146107825780639e1a4d1914610797578063a457c2d7146107ad57610357565b80638da5cb5b1461072657806390ed6bf41461075857806395d89b411461076d57610357565b80638427a581116101745780638427a581146106db578063845a4697146106f05780638a054ac21461071057610357565b806379df4fa2146106825780637a23032c146106975780637f6a92ed146106ad57610357565b806335c24a881161025e57806352fb8b031161020757806370a08231116101e157806370a0823114610621578063715018a61461065757806375172a8b1461066c57610357565b806352fb8b03146105e15780635860638d146105f757806358ba94d71461060c57610357565b8063488cb84111610238578063488cb8411461057e5780634927b44c146105945780634bf6f9e7146105b457610357565b806335c24a8814610533578063372500ab14610549578063395093511461055e57610357565b806328fdb481116102c05780632e1a7d4d1161029a5780632e1a7d4d146104d7578063313ce567146104f75780633536a1dc1461051357610357565b806328fdb481146104755780632d46f63e146104955780632d8fe99a146104b557610357565b80630ec33022116102f15780630ec330221461042a57806318160ddd1461044057806323b872dd1461045557610357565b806306fdde031461038d578063095ea7b3146103b85780630dbe671f146103e857610357565b366103575760405162461bcd60e51b815260206004820152600b60248201526a155b9cdd5c1c1bdc9d195960aa1b60448201526064015b60405180910390fd5b60405162461bcd60e51b815260206004820152600b60248201526a155b9cdd5c1c1bdc9d195960aa1b604482015260640161034e565b34801561039957600080fd5b506103a261094e565b6040516103af9190612b31565b60405180910390f35b3480156103c457600080fd5b506103d86103d3366004612b80565b6109e0565b60405190151581526020016103af565b3480156103f457600080fd5b5061041c7f000000000000000000000000000000000000000000000000000000000000001481565b6040519081526020016103af565b34801561043657600080fd5b5061041c600c5481565b34801561044c57600080fd5b5060035461041c565b34801561046157600080fd5b506103d8610470366004612baa565b6109fa565b34801561048157600080fd5b5061041c610490366004612bf4565b610a20565b3480156104a157600080fd5b5061041c6104b0366004612c34565b610d1d565b3480156104c157600080fd5b506104d56104d0366004612c7c565b6110dd565b005b3480156104e357600080fd5b506104d56104f2366004612c7c565b61113c565b34801561050357600080fd5b50604051600381526020016103af565b34801561051f57600080fd5b506104d561052e366004612c95565b611371565b34801561053f57600080fd5b5061041c600d5481565b34801561055557600080fd5b506104d56113e7565b34801561056a57600080fd5b506103d8610579366004612b80565b6114b9565b34801561058a57600080fd5b5061041c60085481565b3480156105a057600080fd5b506104d56105af366004612cb9565b6114f8565b3480156105c057600080fd5b5061041c6105cf366004612cb9565b60076020526000908152604090205481565b3480156105ed57600080fd5b5061041c60065481565b34801561060357600080fd5b506104d561152f565b34801561061857600080fd5b506104d5611590565b34801561062d57600080fd5b5061041c61063c366004612cb9565b6001600160a01b031660009081526001602052604090205490565b34801561066357600080fd5b506104d56115f1565b34801561067857600080fd5b5061041c600e5481565b34801561068e57600080fd5b506104d5611605565b3480156106a357600080fd5b5061041c60095481565b3480156106b957600080fd5b50600a546106c89061ffff1681565b60405161ffff90911681526020016103af565b3480156106e757600080fd5b506104d5611614565b3480156106fc57600080fd5b5061041c61070b366004612c7c565b611652565b34801561071c57600080fd5b5061041c600f5481565b34801561073257600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016103af565b34801561076457600080fd5b506104d561173f565b34801561077957600080fd5b506103a261174e565b34801561078e57600080fd5b5061041c61175d565b3480156107a357600080fd5b5061041c600b5481565b3480156107b957600080fd5b506103d86107c8366004612b80565b611938565b3480156107d957600080fd5b5061041c60125481565b3480156107ef57600080fd5b506104d56107fe366004612c7c565b6119ed565b34801561080f57600080fd5b506104d561081e366004612cb9565b611c25565b34801561082f57600080fd5b506104d561083e366004612c7c565b611c6d565b34801561084f57600080fd5b5061041c61085e366004612cd4565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b34801561089557600080fd5b5061041c60115481565b3480156108ab57600080fd5b506104d5611ccc565b3480156108c057600080fd5b506104d56108cf366004612cb9565b611d1c565b3480156108e057600080fd5b5061041c6108ef366004612cb9565b611da9565b34801561090057600080fd5b50600a54610740906201000090046001600160a01b031681565b34801561092657600080fd5b506107407f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b60606004805461095d90612d07565b80601f016020809104026020016040519081016040528092919081815260200182805461098990612d07565b80156109d65780601f106109ab576101008083540402835291602001916109d6565b820191906000526020600020905b8154815290600101906020018083116109b957829003601f168201915b5050505050905090565b6000336109ee818585610357565b60019150505b92915050565b600033610a08858285611deb565b610a13858585610357565b60019150505b9392505050565b600a546000906201000090046001600160a01b03163314610a835760405162461bcd60e51b815260206004820152601360248201527f506f6f6c3a206973206e6f7420726f7574657200000000000000000000000000604482015260640161034e565b6000808415610ba85783610ab357600a5461271090610aa69061ffff1687612d57565b610ab09190612d84565b90505b6000610ac7610ac28388612d98565b611e77565b9050610ad281611f1d565b610adc9087612d98565b915080600b6000828254610af09190612dab565b9250508190555080600e6000828254610b099190612dab565b9091555050600b5460405163845a469760e01b8152600091309163845a469791610b399160040190815260200190565b602060405180830381865afa158015610b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7a9190612dbe565b905080600c541115610b975780600c54610b949190612d98565b93505b600c819055610ba583611fbf565b50505b604080516001600160a01b0380891682527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816602082015290810186905260608101839052608081018290527fa930da1d3f27a25892307dd59cec52dd9b881661a0f20364757f83a0da2f68739060a00160405180910390a1509050600c54600b541115610ca357600d54600b54612710600c54610c469190612d57565b610c509190612d84565b1015610c9e5760405162461bcd60e51b815260206004820152601660248201527f506f6f6c3a206c6f7720765553442062616c616e636500000000000000000000604482015260640161034e565b610a19565b600c54600b541015610a1957600d54600c54612710600b54610cc59190612d57565b610ccf9190612d84565b1015610a195760405162461bcd60e51b815260206004820152601760248201527f506f6f6c3a206c6f7720746f6b656e2062616c616e6365000000000000000000604482015260640161034e565b600a546000906201000090046001600160a01b03163314610d805760405162461bcd60e51b815260206004820152601360248201527f506f6f6c3a206973206e6f7420726f7574657200000000000000000000000000604482015260640161034e565b600080808615610f5f5786600c6000828254610d9c9190612dab565b9091555050600c5460405163845a469760e01b8152600091309163845a469791610dcc9160040190815260200190565b602060405180830381865afa158015610de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0d9190612dbe565b905080600b541115610e355780600b54610e279190612d98565b9350610e3284611f1d565b92505b600e54841115610e875760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a207265736572766573000000000000000000000000000000000000604482015260640161034e565b83600e6000828254610e999190612d98565b90915550869050610ec657600a5461271090610eb99061ffff1685612d57565b610ec39190612d84565b91505b600b819055918190039186831015610f205760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a20736c697070616765000000000000000000000000000000000000604482015260640161034e565b610f546001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168a8561203e565b610f5d82611fbf565b505b604080516001600160a01b03808b1682527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816602082015290810188905260608101839052608081018290527ffc1df7b9ba72a13350b8a4e0f094e232eebded9edd179950e74a852a0f4051129060a00160405180910390a150915050600c54600b54111561105b57600d54600b54612710600c54610ffe9190612d57565b6110089190612d84565b10156110565760405162461bcd60e51b815260206004820152601660248201527f506f6f6c3a206c6f7720765553442062616c616e636500000000000000000000604482015260640161034e565b6110d5565b600c54600b5410156110d557600d54600c54612710600b5461107d9190612d57565b6110879190612d84565b10156110d55760405162461bcd60e51b815260206004820152601760248201527f506f6f6c3a206c6f7720746f6b656e2062616c616e6365000000000000000000604482015260640161034e565b949350505050565b6110e56120e7565b6127108111156111375760405162461bcd60e51b815260206004820152601760248201527f5265776172644d616e616765723a20746f6f2068696768000000000000000000604482015260640161034e565b600855565b60125460011461118e5760405162461bcd60e51b815260206004820152601960248201527f506f6f6c3a2077697468647261772070726f6869626974656400000000000000604482015260640161034e565b600f5461119b3383612141565b6000600c54600b546111ad9190612dab565b905080600b54846111be9190612d57565b6111c89190612d84565b600b60008282546111d99190612d98565b9091555050600c5481906111ed9085612d57565b6111f79190612d84565b600c60008282546112089190612d98565b9091555050600c54600b54829161121e91612dab565b1061126b5760405162461bcd60e51b815260206004820152601260248201527f506f6f6c3a207a65726f206368616e6765730000000000000000000000000000604482015260640161034e565b600e548311156112bd5760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a207265736572766573000000000000000000000000000000000000604482015260640161034e565b82600e60008282546112cf9190612d98565b909155506112dd90506122f2565b81600f541061132e5760405162461bcd60e51b815260206004820152601460248201527f506f6f6c3a207a65726f2044206368616e676573000000000000000000000000604482015260640161034e565b61136c3361133b85611f1d565b6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816919061203e565b505050565b6113796120e7565b6127108161ffff1611156113cf5760405162461bcd60e51b815260206004820152600f60248201527f506f6f6c3a20746f6f206c617267650000000000000000000000000000000000604482015260640161034e565b600a805461ffff191661ffff92909216919091179055565b3360009081526001602052604090205480156114b657600060346006548361140f9190612d57565b336000908152600760205260408120549190921c925061142f9083612d98565b9050801561136c5733600081815260076020526040902083905561147e907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b0316908361203e565b60405181815233907ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe9060200160405180910390a250505b50565b3360008181526002602090815260408083206001600160a01b03871684529091528120549091906109ee90829086906114f3908790612dab565b610357565b6115006120e7565b6010805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6010546001600160a01b031633146115895760405162461bcd60e51b815260206004820152601a60248201527f506f6f6c3a206973206e6f742073746f70417574686f72697479000000000000604482015260640161034e565b6000601255565b6010546001600160a01b031633146115ea5760405162461bcd60e51b815260206004820152601a60248201527f506f6f6c3a206973206e6f742073746f70417574686f72697479000000000000604482015260640161034e565b6000601155565b6115f96120e7565b61160360006123ec565b565b61160d6120e7565b6001601155565b61161c6120e7565b600354600f5411156116035761160361163d6000546001600160a01b031690565b600354600f5461164d9190612d98565b612449565b600f546000907f0000000000000000000000000000000000000000000000000000000000000014600281901b9060031b838361168e8782612dd7565b6116989085612df7565b6116a29190612dd7565b905060006116b08280612df7565b6116ba9088612d57565b85806116c68188612d57565b6116d09190612d57565b6116da9190612d57565b6116e49190612dab565b6116ee9088612d57565b90506116fa8784612d57565b61171f611707848a612df7565b6117108461259a565b61171a9190612e27565b6125fb565b6117299190612d84565b611734906001612dab565b979650505050505050565b6117476120e7565b6001601255565b60606005805461095d90612d07565b600b54600f54600091907f000000000000000000000000000000000000000000000000000000000000001460031b9083906117988180612d57565b6117a29190612d57565b600f549091506000906117b58582612dd7565b6117e2907f000000000000000000000000000000000000000000000000000000000000001460021b612df7565b6117ec9190612dd7565b905060006117fa8280612df7565b6118049086612d57565b611831847f000000000000000000000000000000000000000000000000000000000000001460021b612d57565b61183b9190612dab565b6118459086612d57565b9050600085866001600f54901b61185c9190612d57565b6118669190612d57565b86806118728189612d57565b61187c9190612d57565b6118869190612d57565b8788600f5460037f0000000000000000000000000000000000000000000000000000000000000014901b6118ba9190612d57565b6118c49190612d57565b6118ce9190612d57565b6118d89087612e27565b6118e29190612dd7565b6118ec9190612dd7565b905061192d6118fa8361259a565b61190890600289901b612d57565b61191483612710612df7565b61191e9190612e4f565b61171a9061271060011d612e27565b965050505050505090565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909190838110156119d55760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161034e565b6119e28286868403610357565b506001949350505050565b601154600114611a3f5760405162461bcd60e51b815260206004820152601860248201527f506f6f6c3a206465706f7369742070726f686962697465640000000000000000604482015260640161034e565b600f546000611a4d83611e77565b905060008111611a9f5760405162461bcd60e51b815260206004820152601060248201527f506f6f6c3a20746f6f206c6974746c6500000000000000000000000000000000604482015260640161034e565b611ad46001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481633308661264d565b80600e6000828254611ae69190612dab565b9091555050600c54600b54600091611afd91612dab565b9050821580611b0a575080155b15611b4f576000600183901c905080600b6000828254611b2a9190612dab565b9250508190555080600c6000828254611b439190612dab565b90915550611bae915050565b80600b5483611b5e9190612d57565b611b689190612d84565b600b6000828254611b799190612dab565b9091555050600c548190611b8d9084612d57565b611b979190612d84565b600c6000828254611ba89190612dab565b90915550505b611bb66122f2565b611bc83384600f5461164d9190612d98565b65010000000000600b5410611c1f5760405162461bcd60e51b815260206004820152600e60248201527f506f6f6c3a20746f6f206d756368000000000000000000000000000000000000604482015260640161034e565b50505050565b611c2d6120e7565b600a80546001600160a01b0390921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b611c756120e7565b612710811115611cc75760405162461bcd60e51b815260206004820152600f60248201527f506f6f6c3a20746f6f206c617267650000000000000000000000000000000000604482015260640161034e565b600d55565b611cd46120e7565b6009541561160357600954611d15906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481690339061203e565b6000600955565b611d246120e7565b6001600160a01b038116611da05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161034e565b6114b6816123ec565b6001600160a01b0381166000908152600760209081526040808320546006546001909352908320549091603491611de09190612d57565b6109f492911c612d98565b6001600160a01b038381166000908152600260209081526040808320938616835292905220546000198114611c1f5781811015611e6a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161034e565b611c1f8484848403610357565b60007f00000000000000000000000000000000000000000000000000000000000003e815611ec9576109f47f00000000000000000000000000000000000000000000000000000000000003e883612d84565b7f000000000000000000000000000000000000000000000000000000000000000015611f19576109f47f000000000000000000000000000000000000000000000000000000000000000083612d57565b5090565b60007f00000000000000000000000000000000000000000000000000000000000003e815611f6f576109f47f00000000000000000000000000000000000000000000000000000000000003e883612d57565b7f000000000000000000000000000000000000000000000000000000000000000015611f19576109f47f000000000000000000000000000000000000000000000000000000000000000083612d84565b6000611fca60035490565b11156114b657600061271060085483611fe39190612d57565b611fed9190612d84565b90508082039150611ffd60035490565b61200b90603484901b612d84565b6006600082825461201c9190612dab565b9250508190555080600960008282546120359190612dab565b90915550505050565b6040516001600160a01b03831660248201526044810182905261136c9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261269e565b6000546001600160a01b031633146116035760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161034e565b6001600160a01b038216600090815260016020526040902054818110156121aa5760405162461bcd60e51b815260206004820181905260248201527f5265776172644d616e616765723a206e6f7420656e6f75676820616d6f756e74604482015260640161034e565b600081156121e9576001600160a01b0384166000908152600760205260409020546006546034906121db9085612d57565b6121e692911c612d98565b90505b6121f38383612d98565b91506121ff8484612783565b60346006548361220f9190612d57565b6001600160a01b0386166000908152600760205260409020911c905580156122a9576122656001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816858361203e565b836001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe826040516122a091815260200190565b60405180910390a25b836001600160a01b03167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364846040516122e491815260200190565b60405180910390a250505050565b600b54600c5460006123048284612d57565b90507f000000000000000000000000000000000000000000000000000000000000001460006123338486612dab565b61233d8484612d57565b6123479190612d57565b90506000600361235c6001600286901b612d98565b6123669086612d57565b6123709190612d84565b905060006123a5826123828180612d57565b61238c9190612d57565b6123968580612d57565b6123a09190612dab565b61259a565b905060006123b48285016128ee565b9050838211156123d0576123c98483036128ee565b90036123dd565b6123db8285036128ee565b015b60011b600f5550505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038216600090815260016020526040812054801561249f576001600160a01b0384166000908152600760205260409020546006546034906124919084612d57565b61249c92911c612d98565b91505b6124a98382612dab565b90506124b58484612939565b6034600654826124c59190612d57565b6001600160a01b0386166000908152600760205260409020911c9055811561255f5761251b6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816858461203e565b836001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8360405161255691815260200190565b60405180910390a25b836001600160a01b03167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c846040516122e491815260200190565b600081156125f357600182811c8101906000908285816125bc576125bc612d6e565b048301901c90505b808211156125ec5780915060018285816125e0576125e0612d6e565b048301901c90506125c4565b5092915050565b506000919050565b600080821215611f195760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f736974697665604482015260640161034e565b6040516001600160a01b0380851660248301528316604482015260648101829052611c1f9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612083565b60006126f3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129fa9092919063ffffffff16565b80519091501561136c57808060200190518101906127119190612e7d565b61136c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161034e565b6001600160a01b0382166127ff5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161034e565b6001600160a01b0382166000908152600160205260409020548181101561288e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840161034e565b6001600160a01b03831660008181526001602090815260408083208686039055600380548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b600080600160ff1b5b80156125ec57600191821b918281018302600302018082868161291c5761291c612d6e565b041061293057808202850394506001830192505b5060031c6128f7565b6001600160a01b03821661298f5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161034e565b80600360008282546129a19190612dab565b90915550506001600160a01b0382166000818152600160209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60606110d5848460008585600080866001600160a01b03168587604051612a219190612e9a565b60006040518083038185875af1925050503d8060008114612a5e576040519150601f19603f3d011682016040523d82523d6000602084013e612a63565b606091505b50915091506117348783838760608315612ade578251600003612ad7576001600160a01b0385163b612ad75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161034e565b50816110d5565b6110d58383815115612af35781518083602001fd5b8060405162461bcd60e51b815260040161034e9190612b31565b60005b83811015612b28578181015183820152602001612b10565b50506000910152565b6020815260008251806020840152612b50816040850160208701612b0d565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114612b7b57600080fd5b919050565b60008060408385031215612b9357600080fd5b612b9c83612b64565b946020939093013593505050565b600080600060608486031215612bbf57600080fd5b612bc884612b64565b9250612bd660208501612b64565b9150604084013590509250925092565b80151581146114b657600080fd5b600080600060608486031215612c0957600080fd5b612c1284612b64565b9250602084013591506040840135612c2981612be6565b809150509250925092565b60008060008060808587031215612c4a57600080fd5b612c5385612b64565b935060208501359250604085013591506060850135612c7181612be6565b939692955090935050565b600060208284031215612c8e57600080fd5b5035919050565b600060208284031215612ca757600080fd5b813561ffff81168114610a1957600080fd5b600060208284031215612ccb57600080fd5b610a1982612b64565b60008060408385031215612ce757600080fd5b612cf083612b64565b9150612cfe60208401612b64565b90509250929050565b600181811c90821680612d1b57607f821691505b602082108103612d3b57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176109f4576109f4612d41565b634e487b7160e01b600052601260045260246000fd5b600082612d9357612d93612d6e565b500490565b818103818111156109f4576109f4612d41565b808201808211156109f4576109f4612d41565b600060208284031215612dd057600080fd5b5051919050565b81810360008312801583831316838312821617156125ec576125ec612d41565b80820260008212600160ff1b84141615612e1357612e13612d41565b81810583148215176109f4576109f4612d41565b8082018281126000831280158216821582161715612e4757612e47612d41565b505092915050565b600082612e5e57612e5e612d6e565b600160ff1b821460001984141615612e7857612e78612d41565b500590565b600060208284031215612e8f57600080fd5b8151610a1981612be6565b60008251612eac818460208701612b0d565b919091019291505056fea2646970667358221220cf8bbc8d773f3a9e8c446559f4074b1091e3753e4d731f648de781ae83d19e6864736f6c63430008120033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000609c690e8f7d68a59885c9132e812eebdaaf0c9e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000f00000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000c416c6c627269646765204c50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074c502d5553444300000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : router_ (address): 0x609c690e8F7D68a59885c9132e812eEbDaAf0c9e
Arg [1] : a_ (uint256): 20
Arg [2] : token_ (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Arg [3] : feeShareBP_ (uint16): 15
Arg [4] : balanceRatioMinBP_ (uint256): 1000
Arg [5] : lpName (string): Allbridge LP
Arg [6] : lpSymbol (string): LP-USDC
-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 000000000000000000000000609c690e8f7d68a59885c9132e812eebdaaf0c9e
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000014
Arg [2] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [3] : 000000000000000000000000000000000000000000000000000000000000000f
Arg [4] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [5] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [7] : 000000000000000000000000000000000000000000000000000000000000000c
Arg [8] : 416c6c627269646765204c500000000000000000000000000000000000000000
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [10] : 4c502d5553444300000000000000000000000000000000000000000000000000
Deployed Bytecode Sourcemap
515:14235:15:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;14720:21;;-1:-1:-1;;;14720:21:15;;216:2:28;14720:21:15;;;198::28;255:2;235:18;;;228:30;-1:-1:-1;;;274:18:28;;;267:41;325:18;;14720:21:15;;;;;;;;515:14235;14649:21;;-1:-1:-1;;;14649:21:15;;216:2:28;14649:21:15;;;198::28;255:2;235:18;;;228:30;-1:-1:-1;;;274:18:28;;;267:41;325:18;;14649:21:15;14:335:28;2154:98:1;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;4431:197;;;;;;;;;;-1:-1:-1;4431:197:1;;;;;:::i;:::-;;:::i;:::-;;;1635:14:28;;1628:22;1610:41;;1598:2;1583:18;4431:197:1;1470:187:28;1133:23:15;;;;;;;;;;;;;;;;;;1808:25:28;;;1796:2;1781:18;1133:23:15;1662:177:28;1043:23:15;;;;;;;;;;;;;;;;3242:106:1;;;;;;;;;;-1:-1:-1;3329:12:1;;3242:106;;5190:286;;;;;;;;;;-1:-1:-1;5190:286:1;;;;;:::i;:::-;;:::i;6543:999:15:-;;;;;;;;;;-1:-1:-1;6543:999:15;;;;;:::i;:::-;;:::i;8183:1341::-;;;;;;;;;;-1:-1:-1;8183:1341:15;;;;;:::i;:::-;;:::i;1888:187:16:-;;;;;;;;;;-1:-1:-1;1888:187:16;;;;;:::i;:::-;;:::i;:::-;;5106:920:15;;;;;;;;;;-1:-1:-1;5106:920:15;;;;;:::i;:::-;;:::i;2742:82:16:-;;;;;;;;;;-1:-1:-1;2742:82:16;;2816:1;3472:36:28;;3460:2;3445:18;2742:82:16;3330:184:28;9580:156:15;;;;;;;;;;-1:-1:-1;9580:156:15;;;;;:::i;:::-;;:::i;1072:29::-;;;;;;;;;;;;;;;;1311:481:16;;;;;;;;;;;;;:::i;5871:234:1:-;;;;;;;;;;-1:-1:-1;5871:234:1;;;;;:::i;:::-;;:::i;724:27:16:-;;;;;;;;;;;;;;;;10903:116:15;;;;;;;;;;-1:-1:-1;10903:116:15;;;;;:::i;:::-;;:::i;618:58:16:-;;;;;;;;;;-1:-1:-1;618:58:16;;;;;:::i;:::-;;;;;;;;;;;;;;490:30;;;;;;;;;;;;;;;;10580:83:15;;;;;;;;;;;;;:::i;10261:81::-;;;;;;;;;;;;;:::i;3406:125:1:-;;;;;;;;;;-1:-1:-1;3406:125:1;;;;;:::i;:::-;-1:-1:-1;;;;;3506:18:1;3480:7;3506:18;;;:9;:18;;;;;;;3406:125;1831:101:0;;;;;;;;;;;;;:::i;1107:20:15:-;;;;;;;;;;;;;;;;10422:74;;;;;;;;;;;;;:::i;791:26:16:-;;;;;;;;;;;;;;;;956:24:15;;;;;;;;;;-1:-1:-1;956:24:15;;;;;;;;;;;4161:6:28;4149:19;;;4131:38;;4119:2;4104:18;956:24:15;3987:188:28;9742:152:15;;;;;;;;;;;;;:::i;11286:506::-;;;;;;;;;;-1:-1:-1;11286:506:15;;;;;:::i;:::-;;:::i;1162:13::-;;;;;;;;;;;;;;;;1201:85:0;;;;;;;;;;-1:-1:-1;1247:7:0;1273:6;-1:-1:-1;;;;;1273:6:0;1201:85;;;-1:-1:-1;;;;;4344:55:28;;;4326:74;;4314:2;4299:18;1201:85:0;4180:226:28;10746:76:15;;;;;;;;;;;;;:::i;2365:102:1:-;;;;;;;;;;;;;:::i;11922:595:15:-;;;;;;;;;;;;;:::i;1013:24::-;;;;;;;;;;;;;;;;6592:427:1;;;;;;;;;;-1:-1:-1;6592:427:1;;;;;:::i;:::-;;:::i;1468:27:15:-;;;;;;;;;;;;;;;;3890:1016;;;;;;;;;;-1:-1:-1;3890:1016:15;;;;;:::i;:::-;;:::i;11094:88::-;;;;;;;;;;-1:-1:-1;11094:88:15;;;;;:::i;:::-;;:::i;9989:191::-;;;;;;;;;;-1:-1:-1;9989:191:15;;;;;:::i;:::-;;:::i;3974:149:1:-;;;;;;;;;;-1:-1:-1;3974:149:1;;;;;:::i;:::-;-1:-1:-1;;;;;4089:18:1;;;4063:7;4089:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3974:149;1399:26:15;;;;;;;;;;;;;;;;2163:187:16;;;;;;;;;;;;;:::i;2081:198:0:-;;;;;;;;;;-1:-1:-1;2081:198:0;;;;;:::i;:::-;;:::i;2473:158:16:-;;;;;;;;;;-1:-1:-1;2473:158:16;;;;;:::i;:::-;;:::i;986:21:15:-;;;;;;;;;;-1:-1:-1;986:21:15;;;;;;;-1:-1:-1;;;;;986:21:15;;;547:28:16;;;;;;;;;;;;;;;2154:98:1;2208:13;2240:5;2233:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98;:::o;4431:197::-;4514:4;719:10:7;4568:32:1;719:10:7;4584:7:1;4593:6;4568:8;:32::i;:::-;4617:4;4610:11;;;4431:197;;;;;:::o;5190:286::-;5317:4;719:10:7;5373:38:1;5389:4;719:10:7;5404:6:1;5373:15;:38::i;:::-;5421:27;5431:4;5437:2;5441:6;5421:9;:27::i;:::-;5465:4;5458:11;;;5190:286;;;;;;:::o;6543:999:15:-;2482:6;;6684:4;;2482:6;;;-1:-1:-1;;;;;2482:6:15;2492:10;2482:20;2474:52;;;;-1:-1:-1;;;2474:52:15;;5564:2:28;2474:52:15;;;5546:21:28;5603:2;5583:18;;;5576:30;5642:21;5622:18;;;5615:49;5681:18;;2474:52:15;5362:343:28;2474:52:15;6700:11:::2;::::0;6759:10;;6755:686:::2;;6790:7;6785:79;;6833:10;::::0;419:3:16::2;::::0;6824:19:15::2;::::0;6833:10:::2;;6824:6:::0;:19:::2;:::i;:::-;6823:26;;;;:::i;:::-;6817:32;;6785:79;6877:13;6893:32;6912:12;6921:3:::0;6912:6;:12:::2;:::i;:::-;6893:18;:32::i;:::-;6877:48;;7008:30;7029:8;7008:20;:30::i;:::-;6999:39;::::0;:6;:39:::2;:::i;:::-;6993:45;;7143:8;7127:12;;:24;;;;;;;:::i;:::-;;;;;;;;7177:8;7165;;:20;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;7231:12:15::2;::::0;7221:23:::2;::::0;-1:-1:-1;;;7221:23:15;;7200:18:::2;::::0;7221:4:::2;::::0;:9:::2;::::0;:23:::2;::::0;::::2;;1808:25:28::0;;;1796:2;1781:18;;1662:177;7221:23:15::2;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7200:44;;7276:13;7262:11;;:27;7258:102;;;7332:13;7318:11;;:27;;;;:::i;:::-;7309:36;;7258:102;7373:11;:27:::0;;;7414:16:::2;7426:3:::0;7414:11:::2;:16::i;:::-;6771:670;;6755:686;7456:56;::::0;;-1:-1:-1;;;;;7176:15:28;;;7158:34;;7484:5:15::2;7228:15:28::0;7223:2;7208:18;;7201:43;7260:18;;;7253:34;;;7318:2;7303:18;;7296:34;;;7361:3;7346:19;;7339:35;;;7456:56:15::2;::::0;7084:3:28;7069:19;7456:56:15::2;;;;;;;-1:-1:-1::0;7529:6:15;-1:-1:-1;2973:11:15::1;;2958:12;;:26;2954:299;;;3045:17;;3029:12;;419:3:16;3009:11:15;;:16;;;;:::i;:::-;3008:33;;;;:::i;:::-;:54;;3000:89;;;::::0;-1:-1:-1;;;3000:89:15;;7587:2:28;3000:89:15::1;::::0;::::1;7569:21:28::0;7626:2;7606:18;;;7599:30;7665:24;7645:18;;;7638:52;7707:18;;3000:89:15::1;7385:346:28::0;3000:89:15::1;2954:299;;;3125:11;;3110:12;;:26;3106:147;;;3197:17;;3182:11;;419:3:16;3161:12:15;;:17;;;;:::i;:::-;3160:33;;;;:::i;:::-;:54;;3152:90;;;::::0;-1:-1:-1;;;3152:90:15;;7938:2:28;3152:90:15::1;::::0;::::1;7920:21:28::0;7977:2;7957:18;;;7950:30;8016:25;7996:18;;;7989:53;8059:18;;3152:90:15::1;7736:347:28::0;8183:1341:15;2482:6;;8357:4;;2482:6;;;-1:-1:-1;;;;;2482:6:15;2492:10;2482:20;2474:52;;;;-1:-1:-1;;;2474:52:15;;5564:2:28;2474:52:15;;;5546:21:28;5603:2;5583:18;;;5576:30;5642:21;5622:18;;;5615:49;5681:18;;2474:52:15;5362:343:28;2474:52:15;8373:13:::2;::::0;;8471:10;;8467:955:::2;;8512:6;8497:11;;:21;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;8559:11:15::2;::::0;8549:22:::2;::::0;-1:-1:-1;;;8549:22:15;;8532:14:::2;::::0;8549:4:::2;::::0;:9:::2;::::0;:22:::2;::::0;::::2;;1808:25:28::0;;;1796:2;1781:18;;1662:177;8549:22:15::2;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;8532:39;;8604:9;8589:12;;:24;8585:155;;;8659:9;8644:12;;:24;;;;:::i;:::-;8633:35;;8695:30;8716:8;8695:20;:30::i;:::-;8686:39;;8585:155;8874:8;;8862;:20;;8854:47;;;::::0;-1:-1:-1;;;8854:47:15;;8290:2:28;8854:47:15::2;::::0;::::2;8272:21:28::0;8329:2;8309:18;;;8302:30;8368:16;8348:18;;;8341:44;8402:18;;8854:47:15::2;8088:338:28::0;8854:47:15::2;8994:8;8982;;:20;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;9021:7:15;;-1:-1:-1;9016:79:15::2;;9064:10;::::0;419:3:16::2;::::0;9055:19:15::2;::::0;9064:10:::2;;9055:6:::0;:19:::2;:::i;:::-;9054:26;;;;:::i;:::-;9048:32;;9016:79;9244:12;:24:::0;;;9202:13;;;::::2;::::0;9290:26;;::::2;;9282:53;;;::::0;-1:-1:-1;;;9282:53:15;;8633:2:28;9282:53:15::2;::::0;::::2;8615:21:28::0;8672:2;8652:18;;;8645:30;8711:16;8691:18;;;8684:44;8745:18;;9282:53:15::2;8431:338:28::0;9282:53:15::2;9349:32;-1:-1:-1::0;;;;;9349:5:15::2;:18;9368:4:::0;9374:6;9349:18:::2;:32::i;:::-;9395:16;9407:3;9395:11;:16::i;:::-;8483:939;8467:955;9436:58;::::0;;-1:-1:-1;;;;;7176:15:28;;;7158:34;;9466:5:15::2;7228:15:28::0;7223:2;7208:18;;7201:43;7260:18;;;7253:34;;;7318:2;7303:18;;7296:34;;;7361:3;7346:19;;7339:35;;;9436:58:15::2;::::0;7084:3:28;7069:19;9436:58:15::2;;;;;;;-1:-1:-1::0;9511:6:15;-1:-1:-1;;2973:11:15::1;;2958:12;;:26;2954:299;;;3045:17;;3029:12;;419:3:16;3009:11:15;;:16;;;;:::i;:::-;3008:33;;;;:::i;:::-;:54;;3000:89;;;::::0;-1:-1:-1;;;3000:89:15;;7587:2:28;3000:89:15::1;::::0;::::1;7569:21:28::0;7626:2;7606:18;;;7599:30;7665:24;7645:18;;;7638:52;7707:18;;3000:89:15::1;7385:346:28::0;3000:89:15::1;2954:299;;;3125:11;;3110:12;;:26;3106:147;;;3197:17;;3182:11;;419:3:16;3161:12:15;;:17;;;;:::i;:::-;3160:33;;;;:::i;:::-;:54;;3152:90;;;::::0;-1:-1:-1;;;3152:90:15;;7938:2:28;3152:90:15::1;::::0;::::1;7920:21:28::0;7977:2;7957:18;;;7950:30;8016:25;7996:18;;;7989:53;8059:18;;3152:90:15::1;7736:347:28::0;3152:90:15::1;8183:1341:::0;;;;;;:::o;1888:187:16:-;1094:13:0;:11;:13::i;:::-;419:3:16::1;1974:16;:22;;1966:58;;;::::0;-1:-1:-1;;;1966:58:16;;8976:2:28;1966:58:16::1;::::0;::::1;8958:21:28::0;9015:2;8995:18;;;8988:30;9054:25;9034:18;;;9027:53;9097:18;;1966:58:16::1;8774:347:28::0;1966:58:16::1;2034:15;:34:::0;1888:187::o;5106:920:15:-;3621:11;;3636:1;3621:16;3613:54;;;;-1:-1:-1;;;3613:54:15;;9328:2:28;3613:54:15;;;9310:21:28;9367:2;9347:18;;;9340:30;9406:27;9386:18;;;9379:55;9451:18;;3613:54:15;9126:349:28;3613:54:15;5186:1:::1;::::0;5197:33:::1;5209:10;5221:8:::0;5197:11:::1;:33::i;:::-;5367:15;5401:11;;5386:12;;:26;;;;:::i;:::-;5367:46;;5467:10;5451:12;;5440:8;:23;;;;:::i;:::-;5439:38;;;;:::i;:::-;5423:12;;:54;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;5514:11:15::1;::::0;5529:10;;5503:22:::1;::::0;:8;:22:::1;:::i;:::-;5502:37;;;;:::i;:::-;5487:11;;:52;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;5573:11:15::1;::::0;5558:12:::1;::::0;5587:10;;5558:26:::1;::::0;::::1;:::i;:::-;:39;5550:70;;;::::0;-1:-1:-1;;;5550:70:15;;9682:2:28;5550:70:15::1;::::0;::::1;9664:21:28::0;9721:2;9701:18;;;9694:30;9760:20;9740:18;;;9733:48;9798:18;;5550:70:15::1;9480:342:28::0;5550:70:15::1;5716:8;;5704;:20;;5696:47;;;::::0;-1:-1:-1;;;5696:47:15;;8290:2:28;5696:47:15::1;::::0;::::1;8272:21:28::0;8329:2;8309:18;;;8302:30;8368:16;8348:18;;;8341:44;8402:18;;5696:47:15::1;8088:338:28::0;5696:47:15::1;5812:8;5800;;:20;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;5885:10:15::1;::::0;-1:-1:-1;5885:8:15::1;:10::i;:::-;5917:4;5913:1;;:8;5905:41;;;::::0;-1:-1:-1;;;5905:41:15;;10029:2:28;5905:41:15::1;::::0;::::1;10011:21:28::0;10068:2;10048:18;;;10041:30;10107:22;10087:18;;;10080:50;10147:18;;5905:41:15::1;9827:344:28::0;5905:41:15::1;5957:62;5976:10;5988:30;6009:8;5988:20;:30::i;:::-;-1:-1:-1::0;;;;;5957:5:15::1;:18;::::0;:62;:18:::1;:62::i;:::-;5164:862;;5106:920:::0;:::o;9580:156::-;1094:13:0;:11;:13::i;:::-;419:3:16::1;9658:11:15;:17;;;;9650:45;;;::::0;-1:-1:-1;;;9650:45:15;;10378:2:28;9650:45:15::1;::::0;::::1;10360:21:28::0;10417:2;10397:18;;;10390:30;10456:17;10436:18;;;10429:45;10491:18;;9650:45:15::1;10176:339:28::0;9650:45:15::1;9705:10;:24:::0;;-1:-1:-1;;9705:24:15::1;;::::0;;;::::1;::::0;;;::::1;::::0;;9580:156::o;1311:481:16:-;1384:10;1354:17;3506:18:1;;;:9;:18;;;;;;1409:16:16;;1405:381;;1441:12;383:2;1472:18;;1457:12;:33;;;;:::i;:::-;1550:10;1510:12;1535:26;;;:14;:26;;;;;;1456:40;;;;;-1:-1:-1;1525:36:16;;1456:40;1525:36;:::i;:::-;1510:51;-1:-1:-1;1579:11:16;;1575:201;;1625:10;1610:26;;;;:14;:26;;;;;:36;;;1664:39;;:5;-1:-1:-1;;;;;1664:18:16;;1695:7;1664:18;:39::i;:::-;1726:35;;1808:25:28;;;1741:10:16;;1726:35;;1796:2:28;1781:18;1726:35:16;;;;;;;1427:359;;1405:381;1344:448;1311:481::o;5871:234:1:-;719:10:7;5959:4:1;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:1;;;;;;;;;;5959:4;;719:10:7;6013:64:1;;719:10:7;;4089:27:1;;6038:38;;6066:10;;6038:38;:::i;:::-;6013:8;:64::i;10903:116:15:-;1094:13:0;:11;:13::i;:::-;10982::15::1;:30:::0;;-1:-1:-1;;10982:30:15::1;-1:-1:-1::0;;;;;10982:30:15;;;::::1;::::0;;;::::1;::::0;;10903:116::o;10580:83::-;2687:13;;-1:-1:-1;;;;;2687:13:15;2704:10;2687:27;2679:66;;;;-1:-1:-1;;;2679:66:15;;10722:2:28;2679:66:15;;;10704:21:28;10761:2;10741:18;;;10734:30;10800:28;10780:18;;;10773:56;10846:18;;2679:66:15;10520:350:28;2679:66:15;10655:1:::1;10641:11;:15:::0;10580:83::o;10261:81::-;2687:13;;-1:-1:-1;;;;;2687:13:15;2704:10;2687:27;2679:66;;;;-1:-1:-1;;;2679:66:15;;10722:2:28;2679:66:15;;;10704:21:28;10761:2;10741:18;;;10734:30;10800:28;10780:18;;;10773:56;10846:18;;2679:66:15;10520:350:28;2679:66:15;10334:1:::1;10321:10;:14:::0;10261:81::o;1831:101:0:-;1094:13;:11;:13::i;:::-;1895:30:::1;1922:1;1895:18;:30::i;:::-;1831:101::o:0;10422:74:15:-;1094:13:0;:11;:13::i;:::-;10488:1:15::1;10475:10;:14:::0;10422:74::o;9742:152::-;1094:13:0;:11;:13::i;:::-;3329:12:1;;9806:1:15::1;;:17;9802:86;;;9839:38;9850:7;1247::0::0;1273:6;-1:-1:-1;;;;;1273:6:0;;1201:85;9850:7:15::1;3329:12:1::0;;9859:1:15::1;;:17;;;;:::i;:::-;9839:10;:38::i;11286:506::-:0;11357:1;;11331:4;;11398:1;11403;11398:6;;;;11424:7;;11331:4;11357:1;11489:16;11503:1;11357;11489:16;:::i;:::-;11478:28;;11482:2;11478:28;:::i;:::-;:38;;;;:::i;:::-;11466:50;-1:-1:-1;11562:10:15;11609:13;11466:50;;11609:13;:::i;:::-;11600:23;;:1;:23;:::i;:::-;11595:2;;11580:7;11595:2;11580;:7;:::i;:::-;:12;;;;:::i;:::-;:17;;;;:::i;:::-;:43;;;;:::i;:::-;11575:49;;:1;:49;:::i;:::-;11562:62;-1:-1:-1;11742:6:15;11747:1;11742:2;:6;:::i;:::-;11684:54;11723:14;11732:5;11727:1;11723:14;:::i;:::-;11707:12;11713:5;11707;:12::i;:::-;11703:34;;;;:::i;:::-;11684:18;:54::i;:::-;:65;;;;:::i;:::-;:69;;11752:1;11684:69;:::i;:::-;11677:76;11286:506;-1:-1:-1;;;;;;;11286:506:15:o;10746:76::-;1094:13:0;:11;:13::i;:::-;10814:1:15::1;10800:11;:15:::0;10746:76::o;2365:102:1:-;2421:13;2453:7;2446:14;;;;;:::i;11922:595:15:-;11990:12;;12060:1;;11965:4;;11990:12;12022:1;12027;12022:6;;11965:4;;12052:5;12060:1;;12052:5;:::i;:::-;:9;;;;:::i;:::-;12144:1;;12038:23;;-1:-1:-1;12097:6:15;;12121:15;12134:1;12144;12121:15;:::i;:::-;12106:31;;12110:1;12115;12110:6;12106:31;:::i;:::-;:40;;;;:::i;:::-;12097:49;-1:-1:-1;12187:7:15;12231;12097:49;;12231:7;:::i;:::-;12222:17;;:1;:17;:::i;:::-;12202;12213:6;12203:1;12208;12203:6;12202:17;:::i;:::-;:37;;;;:::i;:::-;12197:43;;:1;:43;:::i;:::-;12187:53;;12290:6;12382:1;12378;12373;12368;;:6;;12367:12;;;;:::i;:::-;:16;;;;:::i;:::-;12358:1;;12345:6;12358:1;12345:2;:6;:::i;:::-;:10;;;;:::i;:::-;:14;;;;:::i;:::-;12336:1;12332;12328;;12323;12318;:6;;12317:12;;;;:::i;:::-;:16;;;;:::i;:::-;:20;;;;:::i;:::-;12299:39;;12303:6;12299:39;:::i;:::-;:61;;;;:::i;:::-;:85;;;;:::i;:::-;12290:94;;12439:71;12498:9;12504:2;12498:5;:9::i;:::-;12487:20;;12493:1;12488:6;;;12487:20;:::i;:::-;12472:7;12477:2;657:3;12472:7;:::i;:::-;12471:37;;;;:::i;:::-;12458:51;;657:3;12465:1;12459:7;12458:51;:::i;12439:71::-;12432:78;;;;;;;;11922:595;:::o;6592:427:1:-;719:10:7;6685:4:1;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:1;;;;;;;;;;6685:4;;719:10:7;6829:15:1;6809:16;:35;;6801:85;;;;-1:-1:-1;;;6801:85:1;;12053:2:28;6801:85:1;;;12035:21:28;12092:2;12072:18;;;12065:30;12131:34;12111:18;;;12104:62;12202:7;12182:18;;;12175:35;12227:19;;6801:85:1;11851:401:28;6801:85:1;6920:60;6929:5;6936:7;6964:15;6945:16;:34;6920:8;:60::i;:::-;-1:-1:-1;7008:4:1;;6592:427;-1:-1:-1;;;;6592:427:1:o;3890:1016:15:-;3408:10;;3422:1;3408:15;3400:52;;;;-1:-1:-1;;;3400:52:15;;12459:2:28;3400:52:15;;;12441:21:28;12498:2;12478:18;;;12471:30;12537:26;12517:18;;;12510:54;12581:18;;3400:52:15;12257:348:28;3400:52:15;3966:1:::1;::::0;3954:9:::1;3994:26;4013:6:::0;3994:18:::1;:26::i;:::-;3978:42;;4049:1;4038:8;:12;4030:41;;;::::0;-1:-1:-1;;;4030:41:15;;12812:2:28;4030:41:15::1;::::0;::::1;12794:21:28::0;12851:2;12831:18;;;12824:30;12890:18;12870;;;12863:46;12926:18;;4030:41:15::1;12610:340:28::0;4030:41:15::1;4082:57;-1:-1:-1::0;;;;;4082:5:15::1;:22;4105:10;4125:4;4132:6:::0;4082:22:::1;:57::i;:::-;4206:8;4194;;:20;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;4259:11:15::1;::::0;4244:12:::1;::::0;4225:15:::1;::::0;4244:26:::1;::::0;::::1;:::i;:::-;4225:46:::0;-1:-1:-1;4285:9:15;;;:28:::1;;-1:-1:-1::0;4298:15:15;;4285:28:::1;4281:432;;;4387:15;4417:1;4405:8;:13;;4387:31;;4448:10;4432:12;;:26;;;;;;;:::i;:::-;;;;;;;;4487:10;4472:11;;:25;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;4281:432:15::1;::::0;-1:-1:-1;;4281:432:15::1;;4626:10;4610:12;;4599:8;:23;;;;:::i;:::-;4598:38;;;;:::i;:::-;4582:12;;:54;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;4677:11:15::1;::::0;4692:10;;4666:22:::1;::::0;:8;:22:::1;:::i;:::-;4665:37;;;;:::i;:::-;4650:11;;:52;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;4281:432:15::1;4722:10;:8;:10::i;:::-;4797:32;4808:10;4824:4;4820:1;;:8;;;;:::i;4797:32::-;727:7;4848:12;;:32;4840:59;;;::::0;-1:-1:-1;;;4840:59:15;;13157:2:28;4840:59:15::1;::::0;::::1;13139:21:28::0;13196:2;13176:18;;;13169:30;13235:16;13215:18;;;13208:44;13269:18;;4840:59:15::1;12955:338:28::0;4840:59:15::1;3944:962;;;3890:1016:::0;:::o;11094:88::-;1094:13:0;:11;:13::i;:::-;11159:6:15::1;:16:::0;;-1:-1:-1;;;;;11159:16:15;;::::1;::::0;::::1;::::0;;;::::1;::::0;;;::::1;::::0;;11094:88::o;9989:191::-;1094:13:0;:11;:13::i;:::-;419:3:16::1;10081:18:15;:24;;10073:52;;;::::0;-1:-1:-1;;;10073:52:15;;10378:2:28;10073:52:15::1;::::0;::::1;10360:21:28::0;10417:2;10397:18;;;10390:30;10456:17;10436:18;;;10429:45;10491:18;;10073:52:15::1;10176:339:28::0;10073:52:15::1;10135:17;:38:::0;9989:191::o;2163:187:16:-;1094:13:0;:11;:13::i;:::-;2221:14:16::1;::::0;:18;2217:127:::1;;2286:14;::::0;2255:46:::1;::::0;-1:-1:-1;;;;;2255:5:16::1;:18;::::0;2274:10:::1;::::0;2255:18:::1;:46::i;:::-;2332:1;2315:14;:18:::0;2163:187::o;2081:198:0:-;1094:13;:11;:13::i;:::-;-1:-1:-1;;;;;2169:22:0;::::1;2161:73;;;::::0;-1:-1:-1;;;2161:73:0;;13500:2:28;2161:73:0::1;::::0;::::1;13482:21:28::0;13539:2;13519:18;;;13512:30;13578:34;13558:18;;;13551:62;13649:8;13629:18;;;13622:36;13675:19;;2161:73:0::1;13298:402:28::0;2161:73:0::1;2244:28;2263:8;2244:18;:28::i;2473:158:16:-:0;-1:-1:-1;;;;;2604:20:16;;2533:4;2604:20;;;:14;:20;;;;;;;;;2576:18;;3506:9:1;:18;;;;;;;2604:20:16;;383:2;;2558:36;;;;:::i;:::-;2556:68;;;2557:43;2556:68;:::i;11155:441:1:-;-1:-1:-1;;;;;4089:18:1;;;11285:24;4089:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;-1:-1:-1;;11351:37:1;;11347:243;;11432:6;11412:16;:26;;11404:68;;;;-1:-1:-1;;;11404:68:1;;13907:2:28;11404:68:1;;;13889:21:28;13946:2;13926:18;;;13919:30;13985:31;13965:18;;;13958:59;14034:18;;11404:68:1;13705:353:28;11404:68:1;11514:51;11523:5;11530:7;11558:6;11539:16;:25;11514:8;:51::i;13244:289:15:-;13308:4;13328:17;:21;13324:180;;13372:26;13381:17;13372:6;:26;:::i;13324:180::-;13419:19;:23;13415:89;;13465:28;13474:19;13465:6;:28;:::i;13415:89::-;-1:-1:-1;13520:6:15;13244:289::o;13539:291::-;13605:4;13625:17;:21;13621:180;;13669:26;13678:17;13669:6;:26;:::i;13621:180::-;13716:19;:23;13712:89;;13762:28;13771:19;13762:6;:28;:::i;2953:378:16:-;3032:1;3016:13;3329:12:1;;;3242:106;3016:13:16;:17;3012:313;;;3049:20;419:3;3088:15;;3073:12;:30;;;;:::i;:::-;3072:37;;;;:::i;:::-;3049:60;;3167:15;3151:31;;;;3254:13;3329:12:1;;;3242:106;3254:13:16;3232:35;;383:2;3233:17;;;3232:35;:::i;:::-;3210:18;;:57;;;;;;;:::i;:::-;;;;;;;;3299:15;3281:14;;:33;;;;;;;:::i;:::-;;;;-1:-1:-1;;;2953:378:16;:::o;763:205:5:-;902:58;;-1:-1:-1;;;;;14255:55:28;;902:58:5;;;14237:74:28;14327:18;;;14320:34;;;875:86:5;;895:5;;925:23;;14210:18:28;;902:58:5;;;;-1:-1:-1;;902:58:5;;;;;;;;;;;;;;;;;;;;;;;;;;;875:19;:86::i;1359:130:0:-;1247:7;1273:6;-1:-1:-1;;;;;1273:6:0;719:10:7;1422:23:0;1414:68;;;;-1:-1:-1;;;1414:68:0;;14567:2:28;1414:68:0;;;14549:21:28;;;14586:18;;;14579:30;14645:34;14625:18;;;14618:62;14697:18;;1414:68:0;14365:356:28;4147:672:16;-1:-1:-1;;;;;3506:18:1;;4216:17:16;3506:18:1;;;:9;:18;;;;;;4289:24:16;;;;4281:69;;;;-1:-1:-1;;;4281:69:16;;14928:2:28;4281:69:16;;;14910:21:28;;;14947:18;;;14940:30;15006:34;14986:18;;;14979:62;15058:18;;4281:69:16;14726:356:28;4281:69:16;4360:12;4386:16;;4382:122;;-1:-1:-1;;;;;4473:20:16;;;;;;:14;:20;;;;;;4445:18;;383:2;;4430:33;;:12;:33;:::i;:::-;4428:65;;;4429:40;4428:65;:::i;:::-;4418:75;;4382:122;4513:24;4529:8;4513:24;;:::i;:::-;;;4547:21;4553:4;4559:8;4547:5;:21::i;:::-;383:2;4617:18;;4602:12;:33;;;;:::i;:::-;-1:-1:-1;;;;;4578:20:16;;;;;;:14;:20;;;;;4601:40;;4578:63;;4655:11;;4651:123;;4682:33;-1:-1:-1;;;;;4682:5:16;:18;4701:4;4707:7;4682:18;:33::i;:::-;4749:4;-1:-1:-1;;;;;4734:29:16;;4755:7;4734:29;;;;1808:25:28;;1796:2;1781:18;;1662:177;4734:29:16;;;;;;;;4651:123;4797:4;-1:-1:-1;;;;;4788:24:16;;4803:8;4788:24;;;;1808:25:28;;1796:2;1781:18;;1662:177;4788:24:16;;;;;;;;4206:613;;4147:672;;:::o;12523:715:15:-;12571:12;;12602:11;;12562:6;12767:5;12602:11;12571:12;12767:5;:::i;:::-;12757:15;-1:-1:-1;12792:1:15;12782:7;12844:5;12848:1;12844;:5;:::i;:::-;12833:7;12838:2;12833;:7;:::i;:::-;:17;;;;:::i;:::-;12823:27;-1:-1:-1;12886:7:15;12921:1;12903:13;12915:1;12910;12904:7;;;12903:13;:::i;:::-;12897:20;;:2;:20;:::i;:::-;12896:26;;;;:::i;:::-;12886:36;-1:-1:-1;12955:7:15;12965:33;12886:36;12984:7;12886:36;;12984:7;:::i;:::-;:12;;;;:::i;:::-;12972:7;12977:2;;12972:7;:::i;:::-;12971:26;;;;:::i;:::-;12965:5;:33::i;:::-;12955:43;;13032:7;13042:14;13053:2;13048;:7;13042:5;:14::i;:::-;13032:24;;13079:2;13074;:7;13070:125;;;13107:14;13118:2;13113;:7;13107:5;:14::i;:::-;13101:20;;13070:125;;;13166:14;13177:2;13172;:7;13166:5;:14::i;:::-;13160:20;13070:125;13219:1;13213:7;13208:1;:13;-1:-1:-1;;;;;;;12523:715:15:o;2433:187:0:-;2506:16;2525:6;;-1:-1:-1;;;;;2541:17:0;;;-1:-1:-1;;2541:17:0;;;;;;2573:40;;2525:6;;;;;;;2573:40;;2506:16;2573:40;2496:124;2433:187;:::o;3449:575:16:-;-1:-1:-1;;;;;3506:18:1;;3515:12:16;3506:18:1;;;:9;:18;;;;;;3604:16:16;;3600:120;;-1:-1:-1;;;;;3691:18:16;;;;;;:14;:18;;;;;;3663;;383:2;;3648:33;;:12;:33;:::i;:::-;3646:63;;;3647:40;3646:63;:::i;:::-;3636:73;;3600:120;3729:24;3745:8;3729:24;;:::i;:::-;;;3763:19;3769:2;3773:8;3763:5;:19::i;:::-;383:2;3829:18;;3814:12;:33;;;;:::i;:::-;-1:-1:-1;;;;;3792:18:16;;;;;;:14;:18;;;;;3813:40;;3792:61;;3867:11;;3863:119;;3894:31;-1:-1:-1;;;;;3894:5:16;:18;3913:2;3917:7;3894:18;:31::i;:::-;3959:2;-1:-1:-1;;;;;3944:27:16;;3963:7;3944:27;;;;1808:25:28;;1796:2;1781:18;;1662:177;3944:27:16;;;;;;;;3863:119;4004:2;-1:-1:-1;;;;;3996:21:16;;4008:8;3996:21;;;;1808:25:28;;1796:2;1781:18;;1662:177;13836:377:15;13882:4;13926:5;;13922:253;;13966:1;13961:6;;;13960:12;;;13951:6;;13960:12;13961:1;13960:12;14004:5;;;;:::i;:::-;;14000:1;:9;13999:16;;13990:25;;14033:102;14044:1;14040;:5;14033:102;;;14073:1;14069:5;;14115:1;14109;14105;:5;;;;;:::i;:::-;;14101:1;:9;14100:16;;14096:20;;14033:102;;;-1:-1:-1;14159:1:15;13836:377;-1:-1:-1;;13836:377:15:o;13922:253::-;-1:-1:-1;14195:1:15;;13836:377;-1:-1:-1;13836:377:15:o;17187:168:9:-;17243:7;17279:1;17270:5;:10;;17262:55;;;;-1:-1:-1;;;17262:55:9;;15289:2:28;17262:55:9;;;15271:21:28;;;15308:18;;;15301:30;15367:34;15347:18;;;15340:62;15419:18;;17262:55:9;15087:356:28;974:241:5;1139:68;;-1:-1:-1;;;;;15729:15:28;;;1139:68:5;;;15711:34:28;15781:15;;15761:18;;;15754:43;15813:18;;;15806:34;;;1112:96:5;;1132:5;;1162:27;;15623:18:28;;1139:68:5;15448:398:28;3747:706:5;4166:23;4192:69;4220:4;4192:69;;;;;;;;;;;;;;;;;4200:5;-1:-1:-1;;;;;4192:27:5;;;:69;;;;;:::i;:::-;4275:17;;4166:95;;-1:-1:-1;4275:21:5;4271:176;;4370:10;4359:30;;;;;;;;;;;;:::i;:::-;4351:85;;;;-1:-1:-1;;;4351:85:5;;16303:2:28;4351:85:5;;;16285:21:28;16342:2;16322:18;;;16315:30;16381:34;16361:18;;;16354:62;16452:12;16432:18;;;16425:40;16482:19;;4351:85:5;16101:406:28;9422:659:1;-1:-1:-1;;;;;9505:21:1;;9497:67;;;;-1:-1:-1;;;9497:67:1;;16714:2:28;9497:67:1;;;16696:21:28;16753:2;16733:18;;;16726:30;16792:34;16772:18;;;16765:62;16863:3;16843:18;;;16836:31;16884:19;;9497:67:1;16512:397:28;9497:67:1;-1:-1:-1;;;;;9660:18:1;;9635:22;9660:18;;;:9;:18;;;;;;9696:24;;;;9688:71;;;;-1:-1:-1;;;9688:71:1;;17116:2:28;9688:71:1;;;17098:21:28;17155:2;17135:18;;;17128:30;17194:34;17174:18;;;17167:62;17265:4;17245:18;;;17238:32;17287:19;;9688:71:1;16914:398:28;9688:71:1;-1:-1:-1;;;;;9793:18:1;;;;;;:9;:18;;;;;;;;9814:23;;;9793:44;;9930:12;:22;;;;;;;9978:37;1808:25:28;;;9793:18:1;;;9978:37;;1781:18:28;9978:37:1;;;;;;;5164:862:15::1;;5106:920:::0;:::o;14219:386::-;14265:4;;-1:-1:-1;;;14329:238:15;14353:5;;14329:238;;14393:1;14387:7;;;;14430:5;;;14421:15;;:1;:15;:19;;14466:1;14462;14466;14462:5;;;;:::i;:::-;;:10;14458:95;;14505:1;14501;:5;14496:10;;;;14533:1;14528:6;;;;14458:95;-1:-1:-1;14366:1:15;14360:7;14329:238;;8567:535:1;-1:-1:-1;;;;;8650:21:1;;8642:65;;;;-1:-1:-1;;;8642:65:1;;17519:2:28;8642:65:1;;;17501:21:28;17558:2;17538:18;;;17531:30;17597:33;17577:18;;;17570:61;17648:18;;8642:65:1;17317:355:28;8642:65:1;8794:6;8778:12;;:22;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;8946:18:1;;;;;;:9;:18;;;;;;;;:28;;;;;;8999:37;1808:25:28;;;8999:37:1;;1781:18:28;8999:37:1;;;;;;;8567:535;;:::o;3873:223:6:-;4006:12;4037:52;4059:6;4067:4;4073:1;4076:12;4006;5241;5255:23;5282:6;-1:-1:-1;;;;;5282:11:6;5301:5;5308:4;5282:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5240:73;;;;5330:69;5357:6;5365:7;5374:10;5386:12;7646;7674:7;7670:418;;;7701:10;:17;7722:1;7701:22;7697:286;;-1:-1:-1;;;;;1465:19:6;;;7908:60;;;;-1:-1:-1;;;7908:60:6;;18578:2:28;7908:60:6;;;18560:21:28;18617:2;18597:18;;;18590:30;18656:31;18636:18;;;18629:59;18705:18;;7908:60:6;18376:353:28;7908:60:6;-1:-1:-1;8003:10:6;7996:17;;7670:418;8044:33;8052:10;8064:12;8775:17;;:21;8771:379;;9003:10;8997:17;9059:15;9046:10;9042:2;9038:19;9031:44;8771:379;9126:12;9119:20;;-1:-1:-1;;;9119:20:6;;;;;;;;:::i;354:250:28:-;439:1;449:113;463:6;460:1;457:13;449:113;;;539:11;;;533:18;520:11;;;513:39;485:2;478:10;449:113;;;-1:-1:-1;;596:1:28;578:16;;571:27;354:250::o;609:396::-;758:2;747:9;740:21;721:4;790:6;784:13;833:6;828:2;817:9;813:18;806:34;849:79;921:6;916:2;905:9;901:18;896:2;888:6;884:15;849:79;:::i;:::-;989:2;968:15;-1:-1:-1;;964:29:28;949:45;;;;996:2;945:54;;609:396;-1:-1:-1;;609:396:28:o;1010:196::-;1078:20;;-1:-1:-1;;;;;1127:54:28;;1117:65;;1107:93;;1196:1;1193;1186:12;1107:93;1010:196;;;:::o;1211:254::-;1279:6;1287;1340:2;1328:9;1319:7;1315:23;1311:32;1308:52;;;1356:1;1353;1346:12;1308:52;1379:29;1398:9;1379:29;:::i;:::-;1369:39;1455:2;1440:18;;;;1427:32;;-1:-1:-1;;;1211:254:28:o;1844:328::-;1921:6;1929;1937;1990:2;1978:9;1969:7;1965:23;1961:32;1958:52;;;2006:1;2003;1996:12;1958:52;2029:29;2048:9;2029:29;:::i;:::-;2019:39;;2077:38;2111:2;2100:9;2096:18;2077:38;:::i;:::-;2067:48;;2162:2;2151:9;2147:18;2134:32;2124:42;;1844:328;;;;;:::o;2177:118::-;2263:5;2256:13;2249:21;2242:5;2239:32;2229:60;;2285:1;2282;2275:12;2300:383;2374:6;2382;2390;2443:2;2431:9;2422:7;2418:23;2414:32;2411:52;;;2459:1;2456;2449:12;2411:52;2482:29;2501:9;2482:29;:::i;:::-;2472:39;;2558:2;2547:9;2543:18;2530:32;2520:42;;2612:2;2601:9;2597:18;2584:32;2625:28;2647:5;2625:28;:::i;:::-;2672:5;2662:15;;;2300:383;;;;;:::o;2688:452::-;2771:6;2779;2787;2795;2848:3;2836:9;2827:7;2823:23;2819:33;2816:53;;;2865:1;2862;2855:12;2816:53;2888:29;2907:9;2888:29;:::i;:::-;2878:39;;2964:2;2953:9;2949:18;2936:32;2926:42;;3015:2;3004:9;3000:18;2987:32;2977:42;;3069:2;3058:9;3054:18;3041:32;3082:28;3104:5;3082:28;:::i;:::-;2688:452;;;;-1:-1:-1;2688:452:28;;-1:-1:-1;;2688:452:28:o;3145:180::-;3204:6;3257:2;3245:9;3236:7;3232:23;3228:32;3225:52;;;3273:1;3270;3263:12;3225:52;-1:-1:-1;3296:23:28;;3145:180;-1:-1:-1;3145:180:28:o;3519:272::-;3577:6;3630:2;3618:9;3609:7;3605:23;3601:32;3598:52;;;3646:1;3643;3636:12;3598:52;3685:9;3672:23;3735:6;3728:5;3724:18;3717:5;3714:29;3704:57;;3757:1;3754;3747:12;3796:186;3855:6;3908:2;3896:9;3887:7;3883:23;3879:32;3876:52;;;3924:1;3921;3914:12;3876:52;3947:29;3966:9;3947:29;:::i;4411:260::-;4479:6;4487;4540:2;4528:9;4519:7;4515:23;4511:32;4508:52;;;4556:1;4553;4546:12;4508:52;4579:29;4598:9;4579:29;:::i;:::-;4569:39;;4627:38;4661:2;4650:9;4646:18;4627:38;:::i;:::-;4617:48;;4411:260;;;;;:::o;4920:437::-;4999:1;4995:12;;;;5042;;;5063:61;;5117:4;5109:6;5105:17;5095:27;;5063:61;5170:2;5162:6;5159:14;5139:18;5136:38;5133:218;;-1:-1:-1;;;5204:1:28;5197:88;5308:4;5305:1;5298:15;5336:4;5333:1;5326:15;5133:218;;4920:437;;;:::o;5710:184::-;-1:-1:-1;;;5759:1:28;5752:88;5859:4;5856:1;5849:15;5883:4;5880:1;5873:15;5899:168;5972:9;;;6003;;6020:15;;;6014:22;;6000:37;5990:71;;6041:18;;:::i;6072:184::-;-1:-1:-1;;;6121:1:28;6114:88;6221:4;6218:1;6211:15;6245:4;6242:1;6235:15;6261:120;6301:1;6327;6317:35;;6332:18;;:::i;:::-;-1:-1:-1;6366:9:28;;6261:120::o;6386:128::-;6453:9;;;6474:11;;;6471:37;;;6488:18;;:::i;6519:125::-;6584:9;;;6605:10;;;6602:36;;;6618:18;;:::i;6649:184::-;6719:6;6772:2;6760:9;6751:7;6747:23;6743:32;6740:52;;;6788:1;6785;6778:12;6740:52;-1:-1:-1;6811:16:28;;6649:184;-1:-1:-1;6649:184:28:o;10875:200::-;10941:9;;;10914:4;10969:9;;10997:10;;11009:12;;;10993:29;11032:12;;;11024:21;;10990:56;10987:82;;;11049:18;;:::i;11080:292::-;11152:9;;;11119:7;11177:9;;-1:-1:-1;;;11188:73:28;;11173:89;11170:115;;;11265:18;;:::i;:::-;11338:1;11329:7;11324:16;11321:1;11318:23;11314:1;11307:9;11304:38;11294:72;;11346:18;;:::i;11377:216::-;11441:9;;;11469:11;;;11416:3;11499:9;;11527:10;;11523:19;;11552:10;;11544:19;;11520:44;11517:70;;;11567:18;;:::i;:::-;11517:70;;11377:216;;;;:::o;11598:248::-;11637:1;11663;11653:35;;11668:18;;:::i;:::-;-1:-1:-1;;;11704:73:28;;-1:-1:-1;;11779:13:28;;11700:93;11697:119;;;11796:18;;:::i;:::-;-1:-1:-1;11830:10:28;;11598:248::o;15851:245::-;15918:6;15971:2;15959:9;15950:7;15946:23;15942:32;15939:52;;;15987:1;15984;15977:12;15939:52;16019:9;16013:16;16038:28;16060:5;16038:28;:::i;18084:287::-;18213:3;18251:6;18245:13;18267:66;18326:6;18321:3;18314:4;18306:6;18302:17;18267:66;:::i;:::-;18349:16;;;;;18084:287;-1:-1:-1;;18084:287:28:o
Swarm Source
ipfs://cf8bbc8d773f3a9e8c446559f4074b1091e3753e4d731f648de781ae83d19e68
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.