More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 149 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Approve | 10060897 | 484 days ago | IN | 0 ETH | 0.00000193 | ||||
| Transfer | 6080911 | 576 days ago | IN | 0 ETH | 0.00015469 | ||||
| Deposit Exact In | 6072801 | 577 days ago | IN | 0 ETH | 0.00000839 | ||||
| Approve | 5553997 | 589 days ago | IN | 0 ETH | 0.0000014 | ||||
| Approve | 4987597 | 606 days ago | IN | 0 ETH | 0.00000224 | ||||
| Approve | 3863835 | 645 days ago | IN | 0 ETH | 0.00001151 | ||||
| Approve | 3820758 | 647 days ago | IN | 0 ETH | 0.00000339 | ||||
| Approve | 3799532 | 647 days ago | IN | 0 ETH | 0.00000369 | ||||
| Approve | 3480166 | 658 days ago | IN | 0 ETH | 0.00000349 | ||||
| Approve | 3449291 | 660 days ago | IN | 0 ETH | 0.00000335 | ||||
| Approve | 3449266 | 660 days ago | IN | 0 ETH | 0.00000335 | ||||
| Approve | 3428704 | 660 days ago | IN | 0 ETH | 0.00000598 | ||||
| Approve | 3160120 | 670 days ago | IN | 0 ETH | 0.00004728 | ||||
| Approve | 3127016 | 671 days ago | IN | 0 ETH | 0.00003264 | ||||
| Approve | 3099269 | 673 days ago | IN | 0 ETH | 0.00002598 | ||||
| Transfer | 2861663 | 684 days ago | IN | 0.00001 ETH | 0.00003037 | ||||
| Approve | 2795877 | 687 days ago | IN | 0 ETH | 0.00007581 | ||||
| Approve | 2128869 | 718 days ago | IN | 0 ETH | 0.00013152 | ||||
| Approve | 1890166 | 729 days ago | IN | 0 ETH | 0.00002737 | ||||
| Approve | 1889829 | 729 days ago | IN | 0 ETH | 0.00002721 | ||||
| Approve | 1889329 | 729 days ago | IN | 0 ETH | 0.00002738 | ||||
| Approve | 1889009 | 729 days ago | IN | 0 ETH | 0.00002736 | ||||
| Approve | 1888638 | 729 days ago | IN | 0 ETH | 0.0000268 | ||||
| Approve | 1888318 | 729 days ago | IN | 0 ETH | 0.00002603 | ||||
| Approve | 1820113 | 732 days ago | IN | 0 ETH | 0.00003125 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 18895414 | 259 days ago | 0 ETH | ||||
| 18895414 | 259 days ago | 0 ETH | ||||
| 18895414 | 259 days ago | 0 ETH | ||||
| 18895414 | 259 days ago | 0 ETH | ||||
| 18895414 | 259 days ago | 0 ETH | ||||
| 18895414 | 259 days ago | 0 ETH | ||||
| 17450785 | 303 days ago | 0 ETH | ||||
| 17450785 | 303 days ago | 0 ETH | ||||
| 17450785 | 303 days ago | 0 ETH | ||||
| 17450785 | 303 days ago | 0 ETH | ||||
| 17450785 | 303 days ago | 0 ETH | ||||
| 17450785 | 303 days ago | 0 ETH | ||||
| 13083581 | 413 days ago | 0 ETH | ||||
| 13083581 | 413 days ago | 0 ETH | ||||
| 13083581 | 413 days ago | 0 ETH | ||||
| 13083581 | 413 days ago | 0 ETH | ||||
| 13083581 | 413 days ago | 0 ETH | ||||
| 13083581 | 413 days ago | 0 ETH | ||||
| 12825213 | 419 days ago | 0 ETH | ||||
| 12825213 | 419 days ago | 0 ETH | ||||
| 12825213 | 419 days ago | 0 ETH | ||||
| 12825213 | 419 days ago | 0 ETH | ||||
| 12825213 | 419 days ago | 0 ETH | ||||
| 12825213 | 419 days ago | 0 ETH | ||||
| 12825213 | 419 days ago | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
RebaseWrapper
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
import "../PoolWithLPToken.sol";
import "src/lib/RPow.sol";
import "src/interfaces/IConverter.sol";
import "openzeppelin-contracts/contracts/utils/math/SafeCast.sol";
import "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Upgrade.sol";
import "openzeppelin-contracts/contracts/utils/math/Math.sol";
import "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";
// un
contract RebaseWrapper is IConverter, Pool, ReentrancyGuard, ERC20 {
using TokenLib for Token;
using UncheckedMemory for int128[];
using UncheckedMemory for Token[];
using SafeCast for uint256;
using SafeCast for int256;
Token immutable raw;
uint256 immutable iR;
uint256 immutable iW;
bool immutable allowSkimming;
constructor(IVault vault_, Token raw_, bool allowSkimming_)
Pool(vault_, address(this), address(this))
ERC20(string(abi.encodePacked("Wrapped ", ERC20(raw_.addr()).name())), string(abi.encodePacked("w", raw_.symbol())))
{
raw = raw_;
allowSkimming = allowSkimming_;
uint256 iir;
uint256 iiw;
if (raw < toToken(IERC20(address(this)))) {
iir = 0;
iiw = 1;
} else {
iir = 1;
iiw = 0;
}
iR = iir;
iW = iiw;
}
function velocore__convert(address, Token[] calldata tokens, int128[] memory r, bytes calldata)
external
nonReentrant
onlyVault
{
require(tokens.length == 2);
require(tokens.u(iR) == raw && tokens.u(iW) == toToken(IERC20(address(this))));
int256 rR = r.u(iR);
int256 rW = r.u(iW);
if (rW == type(int128).max) {
require(rR != type(int128).max && rR >= 0);
if (totalSupply() == 0) {
_mint(address(vault), uint256(int256(rR)));
} else {
_mint(
address(vault),
totalSupply() * uint256(int256(rR)) / (raw.balanceOf(address(this)) - uint256(int256(rR)))
);
}
} else if (rR == type(int128).max) {
require(rW != type(int128).max && rW >= 0);
_burn(address(this), uint256(int256(rW)));
raw.transferFrom(
address(this),
address(vault),
raw.balanceOf(address(this)) * uint256(int256(rW)) / (totalSupply() + uint256(int256(rW)))
);
} else if (rW <= 0 && rR >= 0) {
uint256 requiredDeposit;
if (totalSupply() != 0) {
requiredDeposit = Math.ceilDiv(raw.balanceOf(address(this)) * uint256(int256(-rW)), totalSupply());
} else {
requiredDeposit = uint256(int256(-rW));
}
_mint(address(vault), uint256(int256(-rW)));
require(requiredDeposit <= uint256(int256(rR)));
raw.transferFrom(address(this), address(vault), uint256(int256(rR)) - requiredDeposit);
} else if (rW >= 0 && rR <= 0) {
uint256 diff = Math.ceilDiv(totalSupply() * uint256(int256(-rR)), raw.balanceOf(address(this)));
require(diff <= uint256(int256(rW)));
_burn(address(this), diff);
raw.transferFrom(address(this), address(vault), uint256(int256(-rR)));
transfer(address(vault), uint256(int256(rW)) - diff);
}
}
function decimals() public view override returns (uint8) {
return raw.decimals();
}
function skim() external nonReentrant {
require(allowSkimming, "no skim allowed");
raw.transferFrom(address(this), msg.sender, raw.balanceOf(address(this)) - totalSupply());
}
function depositExactOut(uint256 amountOut) external nonReentrant {
uint256 requiredDeposit;
if (totalSupply() != 0) {
requiredDeposit = Math.ceilDiv(raw.balanceOf(address(this)) * uint256(int256(amountOut)), totalSupply());
} else {
requiredDeposit = amountOut;
}
_mint(msg.sender, amountOut);
raw.safeTransferFrom(msg.sender, address(this), requiredDeposit);
}
function depositExactIn(uint256 amountIn) external nonReentrant {
uint256 amountOut;
if (totalSupply() != 0) {
amountOut = totalSupply() * amountIn / raw.balanceOf(address(this));
} else {
amountOut = amountIn;
}
_mint(msg.sender, amountOut);
raw.safeTransferFrom(msg.sender, address(this), amountIn);
}
function withdrawExactOut(uint256 amountOut) external nonReentrant {
uint256 amountIn = Math.ceilDiv(totalSupply() * amountOut, raw.balanceOf(address(this)));
_burn(msg.sender, amountIn);
raw.transferFrom(address(this), msg.sender, amountOut);
}
function withdrawExactIn(uint256 amountIn) external nonReentrant {
uint256 amountOut = raw.balanceOf(address(this)) * amountIn / totalSupply();
_burn(msg.sender, amountIn);
raw.transferFrom(address(this), msg.sender, amountOut);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
import "src/interfaces/IVault.sol";
import "src/lib/Token.sol";
import "./Pool.sol";
/**
* @dev a base contract for pools with single ERC20 lp token.
*
* Two notable features:
* <1>
* Inspired by composable pools of Balancer, it mints MAX_SUPPLY tokens to the vault on initialization, allowing this pool to 'mint' lp tokens from velocore__execute().
* However, the initial mint only happens in vault's perspective; balanceOf() and totalSupply() is customized to trick the vault into thinking it has MAX_SUPPLY tokens.
* when msg.sender != vault, the view functions behave normally.
*
* <2>
* the vault has max allowance on every addresses by default, and this can't be changed.
*/
abstract contract PoolWithLPToken is Pool, IERC20 {
uint128 constant MAX_SUPPLY = uint128(type(uint112).max);
string public name;
string public symbol;
mapping(address => uint256) _balanceOf;
mapping(address => mapping(address => uint256)) _allowance;
function _initialize(string memory name_, string memory symbol_) internal {
name = name_;
symbol = symbol_;
_mintVirtualSupply();
}
function _mintVirtualSupply() internal {
_balanceOf[address(vault)] = MAX_SUPPLY;
vault.notifyInitialSupply(toToken(this), 0, MAX_SUPPLY); // this sets pool balances to the given value.
}
/**
* @dev due to the mechanism of 'minting' by transferring, mint and burn events behave weirdly.
* this function should be called whenever new tokens are created by transferring.
* these simulate minting and burning from/to the vault.
*/
function _simulateMint(uint256 amount) internal {
emit Transfer(address(0), address(vault), amount);
}
function _simulateBurn(uint256 amount) internal {
emit Transfer(address(vault), address(0), amount);
}
/**
* @dev vault balance is subtracted by pool balance to behave "normally"
*/
function balanceOf(address addr) external view returns (uint256) {
if (msg.sender != address(vault) && addr == address(vault)) {
unchecked {
return _balanceOf[addr] - _getPoolBalance(toToken(this));
}
}
return _balanceOf[addr];
}
function decimals() external view virtual returns (uint8) {
return 18;
}
function allowance(address from, address spender) external view returns (uint256) {
return (spender == address(vault)) ? type(uint256).max : _allowance[from][spender];
}
/**
* @dev subtracted by pool balance to behave "normally"
*/
function totalSupply() public view virtual returns (uint256) {
return MAX_SUPPLY - _getPoolBalance(toToken(this));
}
function approve(address spender, uint256 amount) public virtual returns (bool) {
_allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool) {
approve(_spender, _allowance[msg.sender][_spender] + _addedValue);
return true;
}
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool) {
approve(_spender, _allowance[msg.sender][_spender] - _subtractedValue);
return true;
}
function transfer(address to, uint256 amount) public virtual returns (bool) {
_balanceOf[msg.sender] -= amount;
unchecked {
_balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {
if (msg.sender != address(vault)) {
uint256 allowed = _allowance[from][msg.sender];
if (allowed != type(uint256).max) _allowance[from][msg.sender] = allowed - amount;
}
_balanceOf[from] -= amount;
unchecked {
_balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
}// SPDX-License-Identifier: AUNLICENSED // From MakerDAO DSS // Copyright (C) 2018 Rain <[email protected]> // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. pragma solidity ^0.8.0; function rpow(uint256 x, uint256 n, uint256 base) pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { z := base } default { z := 0 } } default { switch mod(n, 2) case 0 { z := base } default { z := x } let half := div(base, 2) // for rounding. for { n := div(n, 2) } n { n := div(n, 2) } { let xx := mul(x, x) if iszero(eq(div(xx, x), x)) { revert(0, 0) } let xxRound := add(xx, half) if lt(xxRound, xx) { revert(0, 0) } x := div(xxRound, base) if mod(n, 2) { let zx := mul(z, x) if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0, 0) } let zxRound := add(zx, half) if lt(zxRound, zx) { revert(0, 0) } z := div(zxRound, base) } } } } }
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
import "src/lib/Token.sol";
interface IConverter {
/**
* @dev This method is called by Vault.execute().
* Vault will transfer any positively specified amounts directly to the IConverter before calling velocore__convert.
*
* Instead of returning balance delta numbers, IConverter is expected to directly transfer outputs back to vault.
* Vault will measure the difference, and credit the user.
*/
function velocore__convert(address user, Token[] calldata tokens, int128[] memory amounts, bytes calldata data)
external;
}// 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
// 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 (last updated v4.8.3) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/IERC1967.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967Upgrade is IERC1967 {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), 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) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
import "src/interfaces/IAuthorizer.sol";
import "src/interfaces/IFacet.sol";
import "src/interfaces/IGauge.sol";
import "src/interfaces/IConverter.sol";
import "src/interfaces/IBribe.sol";
import "src/interfaces/ISwap.sol";
import "src/lib/Token.sol";
bytes32 constant SSLOT_HYPERCORE_TREASURY = bytes32(uint256(keccak256("hypercore.treasury")) - 1);
bytes32 constant SSLOT_HYPERCORE_AUTHORIZER = bytes32(uint256(keccak256("hypercore.authorizer")) - 1);
bytes32 constant SSLOT_HYPERCORE_ROUTINGTABLE = bytes32(uint256(keccak256("hypercore.routingTable")) - 1);
bytes32 constant SSLOT_HYPERCORE_POOLBALANCES = bytes32(uint256(keccak256("hypercore.poolBalances")) - 1);
bytes32 constant SSLOT_HYPERCORE_USERBALANCES = bytes32(uint256(keccak256("hypercore.userBalances")) - 1);
bytes32 constant SSLOT_HYPERCORE_EMISSIONINFORMATION = bytes32(uint256(keccak256("hypercore.emissionInformation")) - 1);
bytes32 constant SSLOT_REENTRACNYGUARD_LOCKED = bytes32(uint256(keccak256("ReentrancyGuard.locked")) - 1);
bytes32 constant SSLOT_PAUSABLE_PAUSED = bytes32(uint256(keccak256("Pausable.paused")) - 1);
struct VelocoreOperation {
bytes32 poolId;
bytes32[] tokenInformations;
bytes data;
}
interface IVault {
struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}
enum FacetCutAction {
Add,
Replace,
Remove
}
// Add=0, Replace=1, Remove=2
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
event Swap(ISwap indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
event Gauge(IGauge indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
event Convert(IConverter indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
event Vote(IGauge indexed pool, address indexed user, int256 voteDelta);
event UserBalance(address indexed to, address indexed from, Token[] tokenRef, int128[] delta);
event BribeAttached(IGauge indexed gauge, IBribe indexed bribe);
event BribeKilled(IGauge indexed gauge, IBribe indexed bribe);
event GaugeKilled(IGauge indexed gauge, bool killed);
function notifyInitialSupply(Token, uint128, uint128) external;
function attachBribe(IGauge gauge, IBribe bribe) external;
function killBribe(IGauge gauge, IBribe bribe) external;
function killGauge(IGauge gauge, bool t) external;
function ballotToken() external returns (Token);
function emissionToken() external returns (Token);
function execute(Token[] calldata tokenRef, int128[] memory deposit, VelocoreOperation[] calldata ops)
external
payable;
function facets() external view returns (Facet[] memory facets_);
function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);
function facetAddresses() external view returns (address[] memory facetAddresses_);
function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);
function query(address user, Token[] calldata tokenRef, int128[] memory deposit, VelocoreOperation[] calldata ops)
external
returns (int128[] memory);
function admin_setFunctions(address implementation, bytes4[] calldata sigs) external;
function admin_addFacet(IFacet implementation) external;
function admin_setAuthorizer(IAuthorizer auth_) external;
function admin_pause(bool t) external;
function admin_setTreasury(address treasury) external;
function inspect(address lens, bytes memory data) external;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "src/lib/UncheckedMemory.sol";
import "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import "openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
import "openzeppelin-contracts/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol";
// a library for abstracting tokens
// provides a common interface for ERC20, ERC1155, and ERC721 tokens.
bytes32 constant TOKEN_MASK = 0x000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
bytes32 constant ID_MASK = 0x00FFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000;
uint256 constant ID_SHIFT = 160;
bytes32 constant TOKENSPEC_MASK = 0xFF00000000000000000000000000000000000000000000000000000000000000;
string constant NATIVE_TOKEN_SYMBOL = "ETH";
type Token is bytes32;
type TokenSpecType is bytes32;
using {TokenSpec_equals as ==} for TokenSpecType global;
using {Token_equals as ==} for Token global;
using {Token_lt as <} for Token global;
using {Token_lte as <=} for Token global;
using {Token_ne as !=} for Token global;
using UncheckedMemory for Token[];
Token constant NATIVE_TOKEN = Token.wrap(0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE);
function TokenSpec_equals(TokenSpecType a, TokenSpecType b) pure returns (bool) {
return TokenSpecType.unwrap(a) == TokenSpecType.unwrap(b);
}
function Token_equals(Token a, Token b) pure returns (bool) {
return Token.unwrap(a) == Token.unwrap(b);
}
function Token_ne(Token a, Token b) pure returns (bool) {
return Token.unwrap(a) != Token.unwrap(b);
}
function Token_lt(Token a, Token b) pure returns (bool) {
return Token.unwrap(a) < Token.unwrap(b);
}
function Token_lte(Token a, Token b) pure returns (bool) {
return Token.unwrap(a) <= Token.unwrap(b);
}
library TokenSpec {
TokenSpecType constant ERC20 =
TokenSpecType.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
TokenSpecType constant ERC721 =
TokenSpecType.wrap(0x0100000000000000000000000000000000000000000000000000000000000000);
TokenSpecType constant ERC1155 =
TokenSpecType.wrap(0x0200000000000000000000000000000000000000000000000000000000000000);
TokenSpecType constant NATIVE =
TokenSpecType.wrap(0xEE00000000000000000000000000000000000000000000000000000000000000);
}
function toToken(IERC20 tok) pure returns (Token) {
return Token.wrap(bytes32(uint256(uint160(address(tok)))));
}
function toToken(TokenSpecType spec_, uint88 id_, address addr_) pure returns (Token) {
return Token.wrap(
TokenSpecType.unwrap(spec_) | bytes32((bytes32(uint256(id_)) << ID_SHIFT) & ID_MASK)
| bytes32(uint256(uint160(addr_)))
);
}
// binary search on sorted arrays
function _binarySearch(Token[] calldata arr, Token token) view returns (uint256) {
if (arr.length == 0) return type(uint256).max;
uint256 start = 0;
uint256 end = arr.length - 1;
unchecked {
while (start <= end) {
uint256 mid = start + (end - start) / 2;
if (arr.uc(mid) == token) {
return mid;
} else if (arr.uc(mid) < token) {
start = mid + 1;
} else {
if (mid == 0) return type(uint256).max;
end = mid - 1;
}
}
}
return type(uint256).max;
}
// binary search on sorted arrays, memory array version
function _binarySearchM(Token[] memory arr, Token token) view returns (uint256) {
if (arr.length == 0) return type(uint256).max;
uint256 start = 0;
uint256 end = arr.length - 1;
unchecked {
while (start <= end) {
uint256 mid = start + (end - start) / 2;
if (arr.u(mid) == token) {
return mid;
} else if (arr.u(mid) < token) {
start = mid + 1;
} else {
if (mid == 0) return type(uint256).max;
end = mid - 1;
}
}
}
return type(uint256).max;
}
library TokenLib {
using TokenLib for Token;
using TokenLib for bytes32;
using SafeERC20 for IERC20;
using SafeERC20 for IERC20Metadata;
function wrap(bytes32 data) internal pure returns (Token) {
return Token.wrap(data);
}
function unwrap(Token tok) internal pure returns (bytes32) {
return Token.unwrap(tok);
}
function addr(Token tok) internal pure returns (address) {
return address(uint160(uint256(tok.unwrap() & TOKEN_MASK)));
}
function id(Token tok) internal pure returns (uint256) {
return uint256((tok.unwrap() & ID_MASK) >> ID_SHIFT);
}
function spec(Token tok) internal pure returns (TokenSpecType) {
return TokenSpecType.wrap(tok.unwrap() & TOKENSPEC_MASK);
}
function toIERC20(Token tok) internal pure returns (IERC20Metadata) {
return IERC20Metadata(tok.addr());
}
function toIERC1155(Token tok) internal pure returns (IERC1155) {
return IERC1155(tok.addr());
}
function toIERC721(Token tok) internal pure returns (IERC721Metadata) {
return IERC721Metadata(tok.addr());
}
function balanceOf(Token tok, address user) internal view returns (uint256) {
if (tok.spec() == TokenSpec.ERC20) {
require(tok.id() == 0);
return tok.toIERC20().balanceOf(user); // ERC721 balanceOf() has the same signature
} else if (tok.spec() == TokenSpec.ERC1155) {
return tok.toIERC1155().balanceOf(user, tok.id());
} else if (tok.spec() == TokenSpec.ERC721) {
return tok.toIERC721().ownerOf(tok.id()) == user ? 1 : 0;
} else if (tok == NATIVE_TOKEN) {
return user.balance;
}
revert("invalid token");
}
function totalSupply(Token tok) internal view returns (uint256) {
if (tok.spec() == TokenSpec.ERC20) {
require(tok.id() == 0);
return tok.toIERC20().totalSupply(); // ERC721 balanceOf() has the same signature
} else if (tok.spec() == TokenSpec.ERC1155) {
return ERC1155Supply(tok.addr()).totalSupply(tok.id());
} else if (tok.spec() == TokenSpec.ERC721) {
return 1;
} else if (tok == NATIVE_TOKEN) {
revert("ETH total supply unknown");
}
revert("invalid token");
}
function symbol(Token tok) internal view returns (string memory) {
if (tok.spec() == TokenSpec.ERC20) {
require(tok.id() == 0);
return tok.toIERC20().symbol(); // ERC721 balanceOf() has the same signature
} else if (tok.spec() == TokenSpec.ERC1155) {
return "";
} else if (tok.spec() == TokenSpec.ERC721) {
return tok.toIERC721().symbol();
} else if (tok == NATIVE_TOKEN) {
return NATIVE_TOKEN_SYMBOL;
}
revert("invalid token");
}
function decimals(Token tok) internal view returns (uint8) {
if (tok.spec() == TokenSpec.ERC20) {
require(tok.id() == 0);
return IERC20Metadata(tok.addr()).decimals();
} else if (tok == NATIVE_TOKEN) {
return 18;
}
return 0;
}
function transferFrom(Token tok, address from, address to, uint256 amount) internal {
if (tok.spec() == TokenSpec.ERC20) {
require(tok.id() == 0);
if (from == address(this)) {
tok.toIERC20().safeTransfer(to, amount);
} else {
tok.toIERC20().safeTransferFrom(from, to, amount);
}
} else if (tok == NATIVE_TOKEN) {
require(from == address(this), "native token transferFrom is not supported");
assembly {
let success := call(gas(), to, amount, 0, 0, 0, 0)
if iszero(success) { revert(0, 0) }
}
} else if (tok.spec() == TokenSpec.ERC721) {
require(amount == 1, "invalid amount");
tok.toIERC721().safeTransferFrom(from, to, tok.id());
} else if (tok.spec() == TokenSpec.ERC1155) {
tok.toIERC1155().safeTransferFrom(from, to, tok.id(), amount, "");
} else {
revert("invalid token");
}
}
function meteredTransferFrom(Token tok, address from, address to, uint256 amount) internal returns (uint256) {
uint256 balBefore = tok.balanceOf(to);
tok.transferFrom(from, to, amount);
return tok.balanceOf(to) - balBefore;
}
function safeTransferFrom(Token tok, address from, address to, uint256 amount) internal {
require(tok.meteredTransferFrom(from, to, amount) >= amount);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
import "src/lib/Token.sol";
import "src/lib/PoolBalanceLib.sol";
import "src/lib/UncheckedMemory.sol";
import "src/interfaces/IVault.sol";
import "src/interfaces/ISwap.sol";
import "src/interfaces/IAuthorizer.sol";
import "src/VaultStorage.sol";
import "./Satellite.sol";
/**
* @dev a base contract for pools.
*
* - holds pool-specific slot of vault's storage as an immutable value.
* - provides getters for the slot.
*
*/
abstract contract Pool is IPool, Satellite {
using PoolBalanceLib for PoolBalance;
using UncheckedMemory for bytes32[];
using UncheckedMemory for Token[];
bytes32 immutable vaultStorageSlot;
/**
* @param selfAddr doesnt use address(this) because some pools upgradeable, in which case address(this) would be the implementation address.
*/
constructor(IVault vault_, address selfAddr, address factory) Satellite(vault_, factory) {
bytes32 slot = SSLOT_HYPERCORE_POOLBALANCES;
assembly ("memory-safe") {
mstore(0, selfAddr)
mstore(32, slot)
slot := keccak256(0, 64)
}
vaultStorageSlot = slot;
}
/**
* pool balance is stored as two uint128; poolBalance and gaugeBalance.
*/
function _getPoolBalance(Token token) internal view returns (uint256) {
return PoolBalance.wrap(_readVaultStorage(_computeVaultStorageSlot(token))).poolHalf();
}
function _getGaugeBalance(Token token) internal view returns (uint256) {
return PoolBalance.wrap(_readVaultStorage(_computeVaultStorageSlot(token))).gaugeHalf();
}
function _getPoolBalances(Token[] memory tokens) internal view returns (uint256[] memory ret2) {
address vaultAddress = address(vault);
uint256 tokenLength = tokens.length;
bytes32[] memory ret = new bytes32[](tokenLength);
unchecked {
for (uint256 i = 0; i < tokenLength; ++i) {
ret.u(i, _computeVaultStorageSlot(tokens.u(i)));
}
assembly ("memory-safe") {
let len := mload(ret)
mstore(ret, 0x0000000000000000000000000000000000000000000000000000000072656164)
let success :=
staticcall(gas(), vaultAddress, add(ret, 28), add(4, mul(len, 32)), add(ret, 32), mul(32, len))
if iszero(success) { revert(0, 0) }
mstore(ret, len)
}
for (uint256 i = 0; i < tokenLength; ++i) {
ret.u(i, bytes32(PoolBalance.wrap(ret.u(i)).poolHalf()));
}
assembly ("memory-safe") {
ret2 := ret
}
}
}
/**
* @return ret the storage slot for _poolBalances()[selfAddr][token]
*/
function _computeVaultStorageSlot(Token token) internal view returns (bytes32 ret) {
bytes32 vaultStorageSlot_ = vaultStorageSlot;
assembly ("memory-safe") {
mstore(0, token)
mstore(32, vaultStorageSlot_)
ret := keccak256(0, 64)
}
}
function poolParams() external view virtual override returns (bytes memory) {
return "";
}
}// 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 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 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 v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.3) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.9._
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}// SPDX-License-Identifier: UNLICENSED
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.8.0;
interface IAuthorizer {
/**
* @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`.
*/
function canPerform(bytes32 actionId, address account, address where) external view returns (bool);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
interface IFacet {
function initializeFacet() external;
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
import "src/lib/Token.sol";
import "src/interfaces/IPool.sol";
/**
* Gauges are just pools.
* instead of velocore__execute, they interact with velocore__gauge.
* (un)staking is done by putting/extracting staking token (usually LP token) from/into the pool with velocore__gauge.
* harvesting is done by setting the staking amount to zero.
*/
interface IGauge is IPool {
/**
* @dev This method is called by Vault.execute().
* the parameters and return values are the same as velocore__execute.
* The only difference is that the vault will call velocore__emission before calling velocore__gauge.
*/
function velocore__gauge(address user, Token[] calldata tokens, int128[] memory amounts, bytes calldata data)
external
returns (int128[] memory deltaGauge, int128[] memory deltaPool);
/**
* @dev This method is called by Vault.execute() before calling velocore__emission or changing votes.
*
* The vault will credit emitted VC into the gauge balance.
* IGauge is expected to update its internal ledger.
* @param newEmissions newly emitted VCs since last emission
*/
function velocore__emission(uint256 newEmissions) external;
function stakeableTokens() external view returns (Token[] memory);
function stakedTokens(address user) external view returns (uint256[] memory);
function stakedTokens() external view returns (uint256[] memory);
function emissionShare(address user) external view returns (uint256);
function naturalBribes() external view returns (Token[] memory);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
import "src/lib/Token.sol";
import "./IGauge.sol";
import "./IPool.sol";
interface IBribe is IPool {
/**
* @dev This method is called when someone vote/harvest from/to a @param gauge,
* and when this IBribe happens to be attached to the gauge.
*
* Attachment can happen without IBribe's permission. Implementations must verify that @param gauge is correct.
*
* Returns balance deltas; their net differences are credited as bribe.
* deltaExternal must be zero or negative; Vault will take specified amounts from the contract's balance
*
* @param gauge the gauge to bribe for.
* @param elapsed elapsed time after last call; can be used to save gas.
* @return bribeTokens list of tokens to bribe
* @return deltaGauge same order as bribeTokens, the desired change of gauge balance
* @return deltaPool same order as bribeTokens, the desired change of pool balance
* @return deltaExternal same order as bribeTokens, the vault will pull this amount out from the bribe contract with transferFrom()
*/
function velocore__bribe(IGauge gauge, uint256 elapsed)
external
returns (
Token[] memory bribeTokens,
int128[] memory deltaGauge,
int128[] memory deltaPool,
int128[] memory deltaExternal
);
function bribeTokens(IGauge gauge) external view returns (Token[] memory);
function bribeRates(IGauge gauge) external view returns (uint256[] memory);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
import "src/lib/Token.sol";
import "./IPool.sol";
interface ISwap is IPool {
/**
* @param user the user that requested swap
* @param tokens sorted, unique list of tokens that user asked to swap
* @param amounts same order as tokens, requested change of token balance, positive when pool receives, negative when pool gives. type(int128).max for unknown values, for which the pool should decide.
* @param data auxillary data for pool-specific uses.
* @return deltaGauge same order as tokens, the desired change of gauge balance
* @return deltaPool same order as bribeTokens, the desired change of pool balance
*/
function velocore__execute(address user, Token[] calldata tokens, int128[] memory amounts, bytes calldata data)
external
returns (int128[] memory, int128[] memory);
function swapType() external view returns (string memory);
function listedTokens() external view returns (Token[] memory);
function lpTokens() external view returns (Token[] memory);
function underlyingTokens(Token lp) external view returns (Token[] memory);
//function spotPrice(Token token, Token base) external view returns (uint256);
}// SPDX-License-Identifier: AUNLICENSED
pragma solidity ^0.8.0;
import {Token} from "src/lib/Token.sol";
// solidity by default perform bound check for every array access.
// we define functions for unchecked access here
library UncheckedMemory {
function u(bytes32[] memory self, uint256 i) internal view returns (bytes32 ret) {
assembly ("memory-safe") {
ret := mload(add(self, mul(32, add(i, 1))))
}
}
function u(bytes32[] memory self, uint256 i, bytes32 v) internal view {
assembly ("memory-safe") {
mstore(add(self, mul(32, add(i, 1))), v)
}
}
function u(uint256[] memory self, uint256 i) internal view returns (uint256 ret) {
assembly ("memory-safe") {
ret := mload(add(self, mul(32, add(i, 1))))
}
}
function u(uint256[] memory self, uint256 i, uint256 v) internal view {
assembly ("memory-safe") {
mstore(add(self, mul(32, add(i, 1))), v)
}
}
function u(int128[] memory self, uint256 i) internal view returns (int128 ret) {
assembly ("memory-safe") {
ret := mload(add(self, mul(32, add(i, 1))))
}
}
function u(int128[] memory self, uint256 i, int128 v) internal view {
assembly ("memory-safe") {
mstore(add(self, mul(32, add(i, 1))), v)
}
}
// uc instead u for calldata array; as solidity does not support type-location overloading.
function uc(Token[] calldata self, uint256 i) internal view returns (Token ret) {
assembly ("memory-safe") {
ret := calldataload(add(self.offset, mul(32, i)))
}
}
function u(Token[] memory self, uint256 i) internal view returns (Token ret) {
assembly ("memory-safe") {
ret := mload(add(self, mul(32, add(i, 1))))
}
}
function u(Token[] memory self, uint256 i, Token v) internal view {
assembly ("memory-safe") {
mstore(add(self, mul(32, add(i, 1))), v)
}
}
}// 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.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol)
pragma solidity ^0.8.0;
import "../ERC1155.sol";
/**
* @dev Extension of ERC1155 that adds tracking of total supply per id.
*
* Useful for scenarios where Fungible and Non-fungible tokens have to be
* clearly identified. Note: While a totalSupply of 1 might mean the
* corresponding is an NFT, there is no guarantees that no other token with the
* same id are not going to be minted.
*/
abstract contract ERC1155Supply is ERC1155 {
mapping(uint256 => uint256) private _totalSupply;
/**
* @dev Total amount of tokens in with a given id.
*/
function totalSupply(uint256 id) public view virtual returns (uint256) {
return _totalSupply[id];
}
/**
* @dev Indicates whether any token exist with a given id, or not.
*/
function exists(uint256 id) public view virtual returns (bool) {
return ERC1155Supply.totalSupply(id) > 0;
}
/**
* @dev See {ERC1155-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
if (from == address(0)) {
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] += amounts[i];
}
}
if (to == address(0)) {
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 supply = _totalSupply[id];
require(supply >= amount, "ERC1155: burn amount exceeds totalSupply");
unchecked {
_totalSupply[id] = supply - amount;
}
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: AUNLICENSED
pragma solidity ^0.8.0;
import "openzeppelin-contracts/contracts/utils/math/SafeCast.sol";
// a pool's balances are stored as two uint128;
// the only difference between them is that new emissions are credited into the gauge balance.
// the pool can use them in any way they want.
type PoolBalance is bytes32;
library PoolBalanceLib {
using PoolBalanceLib for PoolBalance;
using SafeCast for uint256;
using SafeCast for int256;
function gaugeHalf(PoolBalance self) internal pure returns (uint256) {
return uint128(bytes16(PoolBalance.unwrap(self)));
}
function poolHalf(PoolBalance self) internal pure returns (uint256) {
return uint128(uint256(PoolBalance.unwrap(self)));
}
function pack(uint256 a, uint256 b) internal pure returns (PoolBalance) {
uint128 a_ = uint128(a);
uint128 b_ = uint128(b);
require(b == b_ && a == a_, "overflow");
return PoolBalance.wrap(bytes32(bytes16(a_)) | bytes32(uint256(b_)));
}
function credit(PoolBalance self, int256 dGauge, int256 dPool) internal pure returns (PoolBalance) {
return pack(
(int256(uint256(self.gaugeHalf())) + dGauge).toUint256(),
(int256(uint256(self.poolHalf())) + dPool).toUint256()
);
}
function credit(PoolBalance self, int256 dPool) internal pure returns (PoolBalance) {
return pack(self.gaugeHalf(), (int256(uint256(self.poolHalf())) + dPool).toUint256());
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
import "src/lib/Token.sol";
import "src/interfaces/IVault.sol";
import "src/interfaces/IGauge.sol";
import "src/lib/PoolBalanceLib.sol";
import "src/interfaces/IGauge.sol";
import "src/interfaces/IBribe.sol";
import "src/interfaces/IAuthorizer.sol";
import "openzeppelin-contracts/contracts/utils/structs/BitMaps.sol";
import "openzeppelin-contracts/contracts/utils/StorageSlot.sol";
import "openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol";
// A base contract inherited by every facet.
// Vault stores everything on named slots, in order to:
// - prevent storage collision
// - make information access cheaper. (see Diamond.yul)
// The downside of doing that is that storage access becomes exteremely verbose;
// We define large singleton structs to mitigate that.
struct EmissionInformation {
// a singleton struct for emission-related global data
// accessed as `_e()`
uint128 perVote; // (number of VC tokens ever emitted, per vote) * 1e9; monotonically increasing.
uint128 totalVotes; // the current sum of votes on all pool
mapping(IGauge => GaugeInformation) gauges; // per-guage informations
}
struct GaugeInformation {
// we use `lastBribeUpdate == 1` as a special value indicating a killed gauge
// note that this is updated with bribe calculation, not emission calculation, unlike perVoteAtLastEmissionUpdate
uint32 lastBribeUpdate;
uint112 perVoteAtLastEmissionUpdate;
//
// total vote on this gauge
uint112 totalVotes;
//
mapping(address => uint256) userVotes;
//
// bribes are contracts; we call them to extort bribes on demand
EnumerableSet.AddressSet bribes;
//
// for storing extorted bribes.
// we track (accumulated reward / vote), per bribe contract, per token
// we separately track rewards from different bribes, to contain bad-behaving bribe contracts
mapping(IBribe => mapping(Token => Rewards)) rewards;
}
// tracks the distribution of a single token
struct Rewards {
// accumulated rewards per vote * 1e9
uint256 current;
// `accumulated rewards per vote * 1e9` at the moment of last claim of the user
mapping(address => uint256) snapshots;
}
struct RoutingTable {
EnumerableSet.Bytes32Set sigs;
mapping(address => EnumerableSet.Bytes32Set) sigsByImplementation;
}
contract VaultStorage {
using EnumerableSet for EnumerableSet.Bytes32Set;
event Swap(ISwap indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
event Gauge(IGauge indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
event Convert(IConverter indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
event Vote(IGauge indexed pool, address indexed user, int256 voteDelta);
event UserBalance(address indexed to, address indexed from, Token[] tokenRef, int128[] delta);
event BribeAttached(IGauge indexed gauge, IBribe indexed bribe);
event BribeKilled(IGauge indexed gauge, IBribe indexed bribe);
event GaugeKilled(IGauge indexed gauge, bool killed);
enum FacetCutAction {
Add,
Replace,
Remove
}
// Add=0, Replace=1, Remove=2
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
function _getImplementation(bytes4 sig) internal view returns (address impl, bool readonly) {
assembly ("memory-safe") {
impl := sload(not(shr(0xe0, sig)))
if iszero(lt(impl, 0x10000000000000000000000000000000000000000)) {
readonly := 1
impl := not(impl)
}
}
}
function _setFunction(bytes4 sig, address implementation) internal {
(address oldImplementation,) = _getImplementation(sig);
FacetCut[] memory a = new FacetCut[](1);
a[0].facetAddress = implementation;
a[0].action = FacetCutAction.Add;
a[0].functionSelectors = new bytes4[](1);
a[0].functionSelectors[0] = sig;
if (oldImplementation != address(0)) a[0].action = FacetCutAction.Replace;
if (implementation == address(0)) a[0].action = FacetCutAction.Remove;
emit DiamondCut(a, implementation, "");
assembly ("memory-safe") {
sstore(not(shr(0xe0, sig)), implementation)
}
if (oldImplementation != address(0)) {
_routingTable().sigsByImplementation[oldImplementation].remove(sig);
}
if (implementation == address(0)) {
_routingTable().sigs.remove(sig);
} else {
_routingTable().sigs.add(sig);
_routingTable().sigsByImplementation[implementation].add(sig);
}
}
// viewer implementations are stored as `not(implementation)`. please refer to Diamond.yul for more information
function _setViewer(bytes4 sig, address implementation) internal {
(address oldImplementation,) = _getImplementation(sig);
FacetCut[] memory a = new FacetCut[](1);
a[0].facetAddress = implementation;
a[0].action = FacetCutAction.Add;
a[0].functionSelectors = new bytes4[](1);
a[0].functionSelectors[0] = sig;
if (oldImplementation != address(0)) a[0].action = FacetCutAction.Replace;
if (implementation == address(0)) a[0].action = FacetCutAction.Remove;
emit DiamondCut(a, implementation, "");
assembly ("memory-safe") {
sstore(not(shr(0xe0, sig)), not(implementation))
}
if (oldImplementation != address(0)) {
_routingTable().sigsByImplementation[oldImplementation].remove(sig);
}
if (implementation == address(0)) {
_routingTable().sigs.remove(sig);
} else {
_routingTable().sigs.add(sig);
_routingTable().sigsByImplementation[implementation].add(sig);
}
}
function _routingTable() internal pure returns (RoutingTable storage ret) {
bytes32 slot = SSLOT_HYPERCORE_ROUTINGTABLE;
assembly ("memory-safe") {
ret.slot := slot
}
}
// each pool has two accounts of balance: gauge balance and pool balance; both are uint128.
// they are stored in a wrapped bytes32, PoolBalance
// the only difference between them is that new emissions are credited into the gauge balance.
// the pool can use them in any way they want.
function _poolBalances() internal pure returns (mapping(IPool => mapping(Token => PoolBalance)) storage ret) {
bytes32 slot = SSLOT_HYPERCORE_POOLBALANCES;
assembly ("memory-safe") {
ret.slot := slot
}
}
function _e() internal pure returns (EmissionInformation storage ret) {
bytes32 slot = SSLOT_HYPERCORE_EMISSIONINFORMATION;
assembly ("memory-safe") {
ret.slot := slot
}
}
// users can also store tokens directly in the vault; their balances are tracked separately.
function _userBalances() internal pure returns (mapping(address => mapping(Token => uint256)) storage ret) {
bytes32 slot = SSLOT_HYPERCORE_USERBALANCES;
assembly ("memory-safe") {
ret.slot := slot
}
}
modifier nonReentrant() {
require(StorageSlot.getUint256Slot(SSLOT_REENTRACNYGUARD_LOCKED).value < 2, "REENTRANCY");
StorageSlot.getUint256Slot(SSLOT_REENTRACNYGUARD_LOCKED).value = 2;
_;
StorageSlot.getUint256Slot(SSLOT_REENTRACNYGUARD_LOCKED).value = 1;
}
modifier whenNotPaused() {
require(StorageSlot.getUint256Slot(SSLOT_PAUSABLE_PAUSED).value == 0, "PAUSED");
_;
}
// this contract delegates access control to another contract, IAuthenticator.
// this design was inspired by Balancer.
// actionId is a function of method signature and contract address
modifier authenticate() {
authenticateCaller();
_;
}
function authenticateCaller() internal {
bytes32 actionId = keccak256(abi.encodePacked(bytes32(uint256(uint160(address(this)))), msg.sig));
require(
IAuthorizer(StorageSlot.getAddressSlot(SSLOT_HYPERCORE_AUTHORIZER).value).canPerform(
actionId, msg.sender, address(this)
),
"unauthorized"
);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
import "src/interfaces/IVault.sol";
/**
* @dev a base contract for peripheral contracts.
*
* 1. delegates access control to the vault
* 2. use Diamond.yul's 'read' intrinsic function to read its storages
*
*/
contract Satellite {
IVault immutable vault;
address immutable factory;
constructor(IVault vault_, address factory_) {
vault = vault_;
factory = factory_;
}
modifier onlyVault() {
require(msg.sender == address(vault), "only vault");
_;
}
function _readVaultStorage(bytes32 slot) internal view returns (bytes32 ret) {
address vaultAddress = address(vault);
assembly ("memory-safe") {
mstore(0, 0x7265616400000000000000000000000000000000000000000000000000000000)
mstore(4, slot)
let success := staticcall(gas(), vaultAddress, 0, 36, 0, 32)
if iszero(success) { revert(0, 0) }
ret := mload(0)
}
}
modifier authenticate() {
require(
IAuthorizer(address(uint160(uint256(_readVaultStorage(SSLOT_HYPERCORE_AUTHORIZER))))).canPerform(
keccak256(abi.encodePacked(bytes32(uint256(uint160(factory))), msg.sig)), msg.sender, address(this)
),
"unauthorized"
);
_;
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;
import "src/lib/Token.sol";
interface IPool {
function poolParams() external view returns (bytes memory);
}// 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 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/BitMaps.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential.
* Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor].
*/
library BitMaps {
struct BitMap {
mapping(uint256 => uint256) _data;
}
/**
* @dev Returns whether the bit at `index` is set.
*/
function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
return bitmap._data[bucket] & mask != 0;
}
/**
* @dev Sets the bit at `index` to the boolean `value`.
*/
function setTo(
BitMap storage bitmap,
uint256 index,
bool value
) internal {
if (value) {
set(bitmap, index);
} else {
unset(bitmap, index);
}
}
/**
* @dev Sets the bit at `index`.
*/
function set(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] |= mask;
}
/**
* @dev Unsets the bit at `index`.
*/
function unset(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] &= ~mask;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}{
"remappings": [
"@prb/test/=lib/prb-math/lib/prb-test/src/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"prb-math/=lib/prb-math/src/",
"prb-test/=lib/prb-math/lib/prb-test/src/",
"solmate/=lib/solmate/src/"
],
"optimizer": {
"enabled": true,
"runs": 1000
},
"metadata": {
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": true,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IVault","name":"vault_","type":"address"},{"internalType":"Token","name":"raw_","type":"bytes32"},{"internalType":"bool","name":"allowSkimming_","type":"bool"}],"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":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"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":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"depositExactIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"depositExactOut","outputs":[],"stateMutability":"nonpayable","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":"poolParams","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"skim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"","type":"address"},{"internalType":"Token[]","name":"tokens","type":"bytes32[]"},{"internalType":"int128[]","name":"r","type":"int128[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"velocore__convert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"withdrawExactIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"withdrawExactOut","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
610160604081815234620004da57606082620026e28038038091620000258285620004df565b833981010312620004da578151916001600160a01b03908184168403620004da576020908382820151910151928315158403620004da578451928380926306fdde0360e01b82526000958691600495869188165afa908115620004d0578591620004a9575b50620000ca6028885180936702bb930b83832b2160c51b86830152620000b98151809288868601910162000519565b8101036008810184520182620004df565b620000d584620005b2565b87518091607760f81b85830152620000f7815180928760218601910162000519565b8101039862000111602160019b8c810185520183620004df565b6080523060a081905286527f41cdc826884889a9d86ce2ed24c534af045774747691a4897641494ae5dd896b835287862060c05288865581516001600160401b03939084811162000496578554938b85811c951680156200048b575b8386101462000478578190601f9586811162000425575b508390868311600114620003b8578a92620003ac575b5050600019600383901b1c1916908b1b1785555b815193841162000399576005948554908b82811c921680156200038e575b838310146200037b5750908184869594931162000326575b5080928411600114620002be57508692620002b2575b5050600019600383901b1c191690871b1790555b8060e0526101409283523011600014620002ab5792915b6101009384526101209283525191611f99938462000749853960805184610f6d015260a05184505060c05184505060e05184818161032b01528181610365015281816105f6015281816107810152818161093001528181610aa301528181610b7d0152610fe501525183610fbb0152518281816110230152611229015251816105d00152f35b9162000225565b015190503880620001fa565b91908a9450601f1984168689528389209389905b8282106200030c5750508411620002f2575b505050811b0190556200020e565b015160001960f88460031b161c19169055388080620002e4565b8484015186558d97909501949384019390810190620002d2565b909192935085885281882084808701881c82019284881062000371575b9187968e929695949301891c01915b82811062000362575050620001e4565b8a81558796508d910162000352565b9250819262000343565b634e487b7160e01b895260229052602488fd5b91607f1691620001cc565b634e487b7160e01b875260418552602487fd5b0151905038806200019a565b888b52848b208e94509190601f1984168c5b87828210620004055750508411620003eb575b505050811b018555620001ae565b015160001960f88460031b161c19169055388080620003dd565b91929395968291958786015181550195019301908f9594939291620003ca565b909150878a52838a208680850160051c8201928686106200046e575b918f91869594930160051c01915b8281106200045f57505062000184565b8c81558594508f91016200044f565b9250819262000441565b634e487b7160e01b895260228752602489fd5b94607f16946200016d565b634e487b7160e01b885260418652602488fd5b620004c991503d8087833e620004c08183620004df565b8101906200053e565b386200008a565b87513d87823e3d90fd5b600080fd5b601f909101601f19168101906001600160401b038211908210176200050357604052565b634e487b7160e01b600052604160045260246000fd5b60005b8381106200052d5750506000910152565b81810151838201526020016200051c565b602081830312620004da5780516001600160401b0391828211620004da57019082601f83011215620004da5781519081116200050357604051926200058e601f8301601f191660200185620004df565b81845260208284010111620004da57620005af916020808501910162000519565b90565b7fff0000000000000000000000000000000000000000000000000000000000000081168062000648575060a081901c6001600160581b0316620004da576040516395d89b4160e01b815290600090829060049082906001600160a01b03165afa9081156200063c5760009162000626575090565b620005af913d8091833e620004c08183620004df565b6040513d6000823e3d90fd5b600160f91b81036200067a575050604051602081016001600160401b0381118282101762000503576040526000815290565b600160f81b03620006bc576040516395d89b4160e01b815290600090829060049082906001600160a01b03165afa9081156200063c5760009162000626575090565b7feeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14620007185760405162461bcd60e51b815260206004820152600d60248201526c34b73b30b634b2103a37b5b2b760991b6044820152606490fd5b604080519081016001600160401b038111828210176200050357604052600381526208aa8960eb1b60208201529056fe6080604052600436101561001257600080fd5b60003560e01c806306fdde0314610137578063095ea7b314610132578063104be3891461012d57806313c679ff1461012857806318160ddd1461012357806319706b381461011e5780631dd19cb41461011957806323b872dd14610114578063313ce5671461010f578063395093511461010a57806370a082311461010557806395d89b4114610100578063a0016517146100fb578063a457c2d7146100f6578063a9059cbb146100f1578063ccd7e3ec146100ec578063dd62ed3e146100e75763efc4a12a146100e257600080fd5b610b3e565b610ad9565b610a70565b610a46565b61097c565b61090f565b61084c565b61080e565b6107b0565b610769565b610688565b6105b4565b610569565b61054b565b6104b5565b6102f2565b6102bd565b6101a0565b600091031261014757565b600080fd5b919082519283825260005b848110610178575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610157565b90602061019d92818152019061014c565b90565b34610147576000806003193601126102a95760405190806004549060019180831c9280821692831561029f575b602092838610851461028b57858852602088019490811561026a5750600114610211575b61020d87610201818903826103e5565b6040519182918261018c565b0390f35b600460005294509192917f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b83861061025957505050910190506102018261020d38806101f1565b80548587015294820194810161023d565b60ff191685525050505090151560051b0190506102018261020d38806101f1565b602482634e487b7160e01b81526022600452fd5b93607f16936101cd565b80fd5b6001600160a01b0381160361014757565b34610147576040366003190112610147576102e76004356102dd816102ac565b6024359033610dfa565b602060405160018152f35b346101475760203660031901126101475761038960043561031161135d565b600354801561039057610359610361916103548461034f307f000000000000000000000000000000000000000000000000000000000000000061163c565b61131d565b6115dc565b915b336113b2565b30337f0000000000000000000000000000000000000000000000000000000000000000611f31565b6001600055005b506103618161035b565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff81116103c457604052565b61039a565b6040810190811067ffffffffffffffff8211176103c457604052565b90601f8019910116810190811067ffffffffffffffff8211176103c457604052565b67ffffffffffffffff81116103c45760051b60200190565b81601f820112156101475780359161043683610407565b9261044460405194856103e5565b808452602092838086019260051b820101928311610147578301905b82821061046e575050505090565b813580600f0b8103610147578152908301908301610460565b9181601f840112156101475782359167ffffffffffffffff8311610147576020838186019501011161014757565b34610147576080366003190112610147576104d16004356102ac565b60243567ffffffffffffffff8082116101475736602383011215610147578160040135818111610147573660248260051b85010111610147576044358281116101475761052290369060040161041f565b9160643590811161014757610549936105416024923690600401610487565b505001610f59565b005b34610147576000366003190112610147576020600354604051908152f35b3461014757600036600319011261014757604051602081019080821067ffffffffffffffff8311176103c45761020d916040526000815260405191829160208352602083019061014c565b34610147576000806003193601126102a9576105ce61135d565b7f000000000000000000000000000000000000000000000000000000000000000015610644577f000000000000000000000000000000000000000000000000000000000000000061061f308261163c565b600354810390811161063f57610638913390309061195a565b6001815580f35b610bc1565b606460405162461bcd60e51b815260206004820152600f60248201527f6e6f20736b696d20616c6c6f77656400000000000000000000000000000000006044820152fd5b34610147576060366003190112610147576004356106a5816102ac565b6024356106b1816102ac565b604435906001600160a01b03831660005260026020526106e8336040600020906001600160a01b0316600052602052604060002090565b549260018401610709575b6106fd9350610cc6565b60405160018152602090f35b82841061072557610720836106fd95033383610dfa565b6106f3565b606460405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152fd5b346101475760003660031901126101475760206107a57f0000000000000000000000000000000000000000000000000000000000000000611e4c565b60ff60405191168152f35b34610147576040366003190112610147576004356107cd816102ac565b3360005260026020526107f7816040600020906001600160a01b0316600052602052604060002090565b54602435810180911161063f576102e79133610dfa565b34610147576020366003190112610147576001600160a01b03600435610833816102ac565b1660005260016020526020604060002054604051908152f35b34610147576000806003193601126102a95760405190806005549060019180831c92808216928315610905575b602092838610851461028b57858852602088019490811561026a57506001146108ac5761020d87610201818903826103e5565b600560005294509192917f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8386106108f457505050910190506102018261020d38806101f1565b8054858701529482019481016108d8565b93607f1693610879565b346101475760203660031901126101475761038960043561092e61135d565b7f000000000000000000000000000000000000000000000000000000000000000061097361096c6109638461034f308661163c565b6003549061133d565b923361146c565b3390309061195a565b3461014757604036600319011261014757600435610999816102ac565b602435903360005260026020526109c7816040600020906001600160a01b0316600052602052604060002090565b54918083106109dc576106fd92039033610dfa565b608460405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152fd5b34610147576040366003190112610147576102e7600435610a66816102ac565b6024359033610cc6565b3461014757602036600319011261014757610389600435610a8f61135d565b610a9b8160035461131d565b610973610ad37f000000000000000000000000000000000000000000000000000000000000000092610acd308561163c565b906115dc565b3361146c565b34610147576040366003190112610147576020610b35600435610afb816102ac565b6001600160a01b0360243591610b10836102ac565b16600052600283526040600020906001600160a01b0316600052602052604060002090565b54604051908152f35b3461014757602036600319011261014757610389600435610b5d61135d565b600354818115610ba757610b7761035b916103619361131d565b610ba1307f000000000000000000000000000000000000000000000000000000000000000061163c565b9061133d565b610361915061035b565b90610bbc9133610cc6565b600190565b634e487b7160e01b600052601160045260246000fd5b9190820180921161063f57565b15610beb57565b608460405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152fd5b15610c5c57565b608460405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152fd5b91906001600160a01b0390818416928315610d9057610d75827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef94610d8b941696610d12881515610be4565b610d5b84610d33836001600160a01b03166000526001602052604060002090565b54610d4082821015610c55565b03916001600160a01b03166000526001602052604060002090565b556001600160a01b03166000526001602052604060002090565b8054820190556040519081529081906020820190565b0390a3565b608460405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b906001600160a01b0391828116928315610ef0578216938415610e865780610e757f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92594610e5d610d8b956001600160a01b03166000526002602052604060002090565b906001600160a01b0316600052602052604060002090565b556040519081529081906020820190565b608460405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b9190610f6361135d565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016908133036112575761101e81610fa8600261104e941461129b565b611015610fb63683896112a2565b9160017f00000000000000000000000000000000000000000000000000000000000000000160051b80930151977f00000000000000000000000000000000000000000000000000000000000000008099149182611219575b505061129b565b840151600f0b90565b9260017f00000000000000000000000000000000000000000000000000000000000000000160051b0151600f0b90565b6f7fffffffffffffffffffffffffffffff908082036110d55750821415806110ca575b61107a9061129b565b600354928361109a575061108e92506113b2565b6110986001600055565b565b610ba1836110ba6110b26110bf95966110c59861131d565b93309061163c565b611330565b906113b2565b61108e565b506000821215611071565b939290810361111f5750611117836110f360006110c596121561129b565b6110fd813061146c565b610ba161110e8261034f308861163c565b91600354610bd7565b91309061195a565b60008413158061120e575b15611190576003546110c59461111792909180156111805761116e61116861117492610354611159308b61163c565b611162886112f0565b9061131d565b936112f0565b856113b2565b6110ba8183111561129b565b5061117461116e611168846112f0565b600084939293121580611203575b6111ac575b5050505061108e565b6111f9936110ba6111f393856111176111d76111cd600354611162896112f0565b610acd308661163c565b956111e48688111561129b565b6111ee873061146c565b6112f0565b90610bb1565b50388080806111a3565b50600081131561119e565b50600081121561112a565b611225925036916112a2565b60017f00000000000000000000000000000000000000000000000000000000000000000160051b01513014388061100e565b606460405162461bcd60e51b815260206004820152600a60248201527f6f6e6c79207661756c74000000000000000000000000000000000000000000006044820152fd5b1561014757565b92916112ad82610407565b916112bb60405193846103e5565b829481845260208094019160051b810192831161014757905b8282106112e15750505050565b813581529083019083016112d4565b7f8000000000000000000000000000000000000000000000000000000000000000811461063f5760000390565b8181029291811591840414171561063f57565b9190820391821161063f57565b8115611347570490565b634e487b7160e01b600052601260045260246000fd5b60026000541461136e576002600055565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b906001600160a01b038216918215611428576003549082820180921161063f576000926114196020927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946003556001600160a01b03166000526001602052604060002090565b818154019055604051908152a3565b606460405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152fd5b6001600160a01b0381169081156115725761149a816001600160a01b03166000526001602052604060002090565b5483811061150857837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef926114ea600096610d8b9403916001600160a01b03166000526001602052604060002090565b556114f88160035403600355565b6040519081529081906020820190565b608460405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152fd5b90816115e9575050600090565b600019820191821161063f576115fe9161133d565b6001810180911161063f5790565b90816020910312610147575161019d816102ac565b6040513d6000823e3d90fd5b90816020910312610147575190565b7fff0000000000000000000000000000000000000000000000000000000000000081168061171757506116d3816001600160a01b039361168e6affffffffffffffffffffff60209560a01c161561129b565b6040519485809481937f70a08231000000000000000000000000000000000000000000000000000000008352600483019190916001600160a01b036020820193169052565b0392165afa908115611712576000916116ea575090565b61019d915060203d811161170b575b61170381836103e5565b81019061162d565b503d6116f9565b611621565b600160f91b810361178157506040517efdd58e0000000000000000000000000000000000000000000000000000000081526001600160a01b03928316600482015260a082901c6affffffffffffffffffffff166024820152916020918391829081604481016116d3565b600160f81b0361183b576040517f6352211e00000000000000000000000000000000000000000000000000000000815260a082901c6affffffffffffffffffffff16600482015290602082806024810103816001600160a01b038095165afa9182156117125760009261180b575b5080600093169116146000146118055750600190565b60ff1690565b61182d91925060203d8111611834575b61182581836103e5565b81019061160c565b90386117ef565b503d61181b565b7feeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461189a5760405162461bcd60e51b815260206004820152600d60248201526c34b73b30b634b2103a37b5b2b760991b6044820152606490fd5b0390fd5b3190565b156118a557565b606460405162461bcd60e51b815260206004820152600e60248201527f696e76616c696420616d6f756e740000000000000000000000000000000000006044820152fd5b156118f057565b608460405162461bcd60e51b815260206004820152602a60248201527f6e617469766520746f6b656e207472616e7366657246726f6d206973206e6f7460448201527f20737570706f72746564000000000000000000000000000000000000000000006064820152fd5b9291907fff000000000000000000000000000000000000000000000000000000000000008416806119c857506119a06affffffffffffffffffffff8560a01c161561129b565b6001600160a01b039080821630036119bd57506110989316611ba4565b906110989416611c05565b7feeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee859293949514600014611a1f575050611a0d906001600160a01b03309116146118e9565b60008080809481945af1156102a95750565b9193909291600160f81b8103611ad557506001611a3c911461189e565b6001600160a01b038216803b15610147576040517f42842e0e0000000000000000000000000000000000000000000000000000000081526001600160a01b03948516600482015293909116602484015260a09190911c6affffffffffffffffffffff1660448301526000908290818381606481015b03925af1801561171257611ac25750565b80611acf611098926103b0565b8061013c565b909290600160f91b03611b6f576001600160a01b03811690813b15610147576040517ff242432a0000000000000000000000000000000000000000000000000000000081526001600160a01b03958616600482015294909216602485015260a091821c6affffffffffffffffffffff16604485015260648401929092526084830152600060a4830181905290829081838160c48101611ab1565b60405162461bcd60e51b815260206004820152600d60248201526c34b73b30b634b2103a37b5b2b760991b6044820152606490fd5b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039092166024830152604482019290925261109891611c0082606481015b03601f1981018452836103e5565b611ce9565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039283166024820152929091166044830152606482019290925261109891611c008260848101611bf2565b90816020910312610147575180151581036101475790565b15611c7f57565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0316604051611cfe816103c9565b6000806020948584527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656486850152858151910182865af13d15611d9a573d9067ffffffffffffffff82116103c457611d759360405192611d6787601f19601f84011601856103e5565b83523d60008785013e611da3565b80519081611d8257505050565b8261109893611d95938301019101611c60565b611c78565b91611d75926060915b91929015611e045750815115611db7575090565b3b15611dc05790565b606460405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015611e175750805190602001fd5b6118969060405191829162461bcd60e51b83526004830161018c565b90816020910312610147575160ff811681036101475790565b7fff000000000000000000000000000000000000000000000000000000000000008116611f0157602081611e986affffffffffffffffffffff6001600160a01b039460a01c161561129b565b6004604051809481937f313ce567000000000000000000000000000000000000000000000000000000008352165afa90811561171257600091611ed9575090565b61019d915060203d8111611efa575b611ef281836103e5565b810190611e33565b503d611ee8565b7feeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14611f2c57600090565b601290565b91611f529192611f4d8583611f46818561163c565b968461195a565b61163c565b90810390811161063f57106101475756fea26469706673582212206e12eadf160f28b24cbd99639a57f9cfbd43cabb210280eb5e562422fb24e5a164736f6c634300081300330000000000000000000000001d0188c4b276a09366d05d6be06af61a73bc7535000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde43760000000000000000000000000000000000000000000000000000000000000001
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806306fdde0314610137578063095ea7b314610132578063104be3891461012d57806313c679ff1461012857806318160ddd1461012357806319706b381461011e5780631dd19cb41461011957806323b872dd14610114578063313ce5671461010f578063395093511461010a57806370a082311461010557806395d89b4114610100578063a0016517146100fb578063a457c2d7146100f6578063a9059cbb146100f1578063ccd7e3ec146100ec578063dd62ed3e146100e75763efc4a12a146100e257600080fd5b610b3e565b610ad9565b610a70565b610a46565b61097c565b61090f565b61084c565b61080e565b6107b0565b610769565b610688565b6105b4565b610569565b61054b565b6104b5565b6102f2565b6102bd565b6101a0565b600091031261014757565b600080fd5b919082519283825260005b848110610178575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610157565b90602061019d92818152019061014c565b90565b34610147576000806003193601126102a95760405190806004549060019180831c9280821692831561029f575b602092838610851461028b57858852602088019490811561026a5750600114610211575b61020d87610201818903826103e5565b6040519182918261018c565b0390f35b600460005294509192917f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b83861061025957505050910190506102018261020d38806101f1565b80548587015294820194810161023d565b60ff191685525050505090151560051b0190506102018261020d38806101f1565b602482634e487b7160e01b81526022600452fd5b93607f16936101cd565b80fd5b6001600160a01b0381160361014757565b34610147576040366003190112610147576102e76004356102dd816102ac565b6024359033610dfa565b602060405160018152f35b346101475760203660031901126101475761038960043561031161135d565b600354801561039057610359610361916103548461034f307f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437661163c565b61131d565b6115dc565b915b336113b2565b30337f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde4376611f31565b6001600055005b506103618161035b565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff81116103c457604052565b61039a565b6040810190811067ffffffffffffffff8211176103c457604052565b90601f8019910116810190811067ffffffffffffffff8211176103c457604052565b67ffffffffffffffff81116103c45760051b60200190565b81601f820112156101475780359161043683610407565b9261044460405194856103e5565b808452602092838086019260051b820101928311610147578301905b82821061046e575050505090565b813580600f0b8103610147578152908301908301610460565b9181601f840112156101475782359167ffffffffffffffff8311610147576020838186019501011161014757565b34610147576080366003190112610147576104d16004356102ac565b60243567ffffffffffffffff8082116101475736602383011215610147578160040135818111610147573660248260051b85010111610147576044358281116101475761052290369060040161041f565b9160643590811161014757610549936105416024923690600401610487565b505001610f59565b005b34610147576000366003190112610147576020600354604051908152f35b3461014757600036600319011261014757604051602081019080821067ffffffffffffffff8311176103c45761020d916040526000815260405191829160208352602083019061014c565b34610147576000806003193601126102a9576105ce61135d565b7f000000000000000000000000000000000000000000000000000000000000000115610644577f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437661061f308261163c565b600354810390811161063f57610638913390309061195a565b6001815580f35b610bc1565b606460405162461bcd60e51b815260206004820152600f60248201527f6e6f20736b696d20616c6c6f77656400000000000000000000000000000000006044820152fd5b34610147576060366003190112610147576004356106a5816102ac565b6024356106b1816102ac565b604435906001600160a01b03831660005260026020526106e8336040600020906001600160a01b0316600052602052604060002090565b549260018401610709575b6106fd9350610cc6565b60405160018152602090f35b82841061072557610720836106fd95033383610dfa565b6106f3565b606460405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152fd5b346101475760003660031901126101475760206107a57f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde4376611e4c565b60ff60405191168152f35b34610147576040366003190112610147576004356107cd816102ac565b3360005260026020526107f7816040600020906001600160a01b0316600052602052604060002090565b54602435810180911161063f576102e79133610dfa565b34610147576020366003190112610147576001600160a01b03600435610833816102ac565b1660005260016020526020604060002054604051908152f35b34610147576000806003193601126102a95760405190806005549060019180831c92808216928315610905575b602092838610851461028b57858852602088019490811561026a57506001146108ac5761020d87610201818903826103e5565b600560005294509192917f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8386106108f457505050910190506102018261020d38806101f1565b8054858701529482019481016108d8565b93607f1693610879565b346101475760203660031901126101475761038960043561092e61135d565b7f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437661097361096c6109638461034f308661163c565b6003549061133d565b923361146c565b3390309061195a565b3461014757604036600319011261014757600435610999816102ac565b602435903360005260026020526109c7816040600020906001600160a01b0316600052602052604060002090565b54918083106109dc576106fd92039033610dfa565b608460405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152fd5b34610147576040366003190112610147576102e7600435610a66816102ac565b6024359033610cc6565b3461014757602036600319011261014757610389600435610a8f61135d565b610a9b8160035461131d565b610973610ad37f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437692610acd308561163c565b906115dc565b3361146c565b34610147576040366003190112610147576020610b35600435610afb816102ac565b6001600160a01b0360243591610b10836102ac565b16600052600283526040600020906001600160a01b0316600052602052604060002090565b54604051908152f35b3461014757602036600319011261014757610389600435610b5d61135d565b600354818115610ba757610b7761035b916103619361131d565b610ba1307f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437661163c565b9061133d565b610361915061035b565b90610bbc9133610cc6565b600190565b634e487b7160e01b600052601160045260246000fd5b9190820180921161063f57565b15610beb57565b608460405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152fd5b15610c5c57565b608460405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152fd5b91906001600160a01b0390818416928315610d9057610d75827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef94610d8b941696610d12881515610be4565b610d5b84610d33836001600160a01b03166000526001602052604060002090565b54610d4082821015610c55565b03916001600160a01b03166000526001602052604060002090565b556001600160a01b03166000526001602052604060002090565b8054820190556040519081529081906020820190565b0390a3565b608460405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b906001600160a01b0391828116928315610ef0578216938415610e865780610e757f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92594610e5d610d8b956001600160a01b03166000526002602052604060002090565b906001600160a01b0316600052602052604060002090565b556040519081529081906020820190565b608460405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b9190610f6361135d565b6001600160a01b037f0000000000000000000000001d0188c4b276a09366d05d6be06af61a73bc753516908133036112575761101e81610fa8600261104e941461129b565b611015610fb63683896112a2565b9160017f00000000000000000000000000000000000000000000000000000000000000010160051b80930151977f000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde43768099149182611219575b505061129b565b840151600f0b90565b9260017f00000000000000000000000000000000000000000000000000000000000000000160051b0151600f0b90565b6f7fffffffffffffffffffffffffffffff908082036110d55750821415806110ca575b61107a9061129b565b600354928361109a575061108e92506113b2565b6110986001600055565b565b610ba1836110ba6110b26110bf95966110c59861131d565b93309061163c565b611330565b906113b2565b61108e565b506000821215611071565b939290810361111f5750611117836110f360006110c596121561129b565b6110fd813061146c565b610ba161110e8261034f308861163c565b91600354610bd7565b91309061195a565b60008413158061120e575b15611190576003546110c59461111792909180156111805761116e61116861117492610354611159308b61163c565b611162886112f0565b9061131d565b936112f0565b856113b2565b6110ba8183111561129b565b5061117461116e611168846112f0565b600084939293121580611203575b6111ac575b5050505061108e565b6111f9936110ba6111f393856111176111d76111cd600354611162896112f0565b610acd308661163c565b956111e48688111561129b565b6111ee873061146c565b6112f0565b90610bb1565b50388080806111a3565b50600081131561119e565b50600081121561112a565b611225925036916112a2565b60017f00000000000000000000000000000000000000000000000000000000000000000160051b01513014388061100e565b606460405162461bcd60e51b815260206004820152600a60248201527f6f6e6c79207661756c74000000000000000000000000000000000000000000006044820152fd5b1561014757565b92916112ad82610407565b916112bb60405193846103e5565b829481845260208094019160051b810192831161014757905b8282106112e15750505050565b813581529083019083016112d4565b7f8000000000000000000000000000000000000000000000000000000000000000811461063f5760000390565b8181029291811591840414171561063f57565b9190820391821161063f57565b8115611347570490565b634e487b7160e01b600052601260045260246000fd5b60026000541461136e576002600055565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b906001600160a01b038216918215611428576003549082820180921161063f576000926114196020927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946003556001600160a01b03166000526001602052604060002090565b818154019055604051908152a3565b606460405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152fd5b6001600160a01b0381169081156115725761149a816001600160a01b03166000526001602052604060002090565b5483811061150857837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef926114ea600096610d8b9403916001600160a01b03166000526001602052604060002090565b556114f88160035403600355565b6040519081529081906020820190565b608460405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152fd5b90816115e9575050600090565b600019820191821161063f576115fe9161133d565b6001810180911161063f5790565b90816020910312610147575161019d816102ac565b6040513d6000823e3d90fd5b90816020910312610147575190565b7fff0000000000000000000000000000000000000000000000000000000000000081168061171757506116d3816001600160a01b039361168e6affffffffffffffffffffff60209560a01c161561129b565b6040519485809481937f70a08231000000000000000000000000000000000000000000000000000000008352600483019190916001600160a01b036020820193169052565b0392165afa908115611712576000916116ea575090565b61019d915060203d811161170b575b61170381836103e5565b81019061162d565b503d6116f9565b611621565b600160f91b810361178157506040517efdd58e0000000000000000000000000000000000000000000000000000000081526001600160a01b03928316600482015260a082901c6affffffffffffffffffffff166024820152916020918391829081604481016116d3565b600160f81b0361183b576040517f6352211e00000000000000000000000000000000000000000000000000000000815260a082901c6affffffffffffffffffffff16600482015290602082806024810103816001600160a01b038095165afa9182156117125760009261180b575b5080600093169116146000146118055750600190565b60ff1690565b61182d91925060203d8111611834575b61182581836103e5565b81019061160c565b90386117ef565b503d61181b565b7feeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461189a5760405162461bcd60e51b815260206004820152600d60248201526c34b73b30b634b2103a37b5b2b760991b6044820152606490fd5b0390fd5b3190565b156118a557565b606460405162461bcd60e51b815260206004820152600e60248201527f696e76616c696420616d6f756e740000000000000000000000000000000000006044820152fd5b156118f057565b608460405162461bcd60e51b815260206004820152602a60248201527f6e617469766520746f6b656e207472616e7366657246726f6d206973206e6f7460448201527f20737570706f72746564000000000000000000000000000000000000000000006064820152fd5b9291907fff000000000000000000000000000000000000000000000000000000000000008416806119c857506119a06affffffffffffffffffffff8560a01c161561129b565b6001600160a01b039080821630036119bd57506110989316611ba4565b906110989416611c05565b7feeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee859293949514600014611a1f575050611a0d906001600160a01b03309116146118e9565b60008080809481945af1156102a95750565b9193909291600160f81b8103611ad557506001611a3c911461189e565b6001600160a01b038216803b15610147576040517f42842e0e0000000000000000000000000000000000000000000000000000000081526001600160a01b03948516600482015293909116602484015260a09190911c6affffffffffffffffffffff1660448301526000908290818381606481015b03925af1801561171257611ac25750565b80611acf611098926103b0565b8061013c565b909290600160f91b03611b6f576001600160a01b03811690813b15610147576040517ff242432a0000000000000000000000000000000000000000000000000000000081526001600160a01b03958616600482015294909216602485015260a091821c6affffffffffffffffffffff16604485015260648401929092526084830152600060a4830181905290829081838160c48101611ab1565b60405162461bcd60e51b815260206004820152600d60248201526c34b73b30b634b2103a37b5b2b760991b6044820152606490fd5b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039092166024830152604482019290925261109891611c0082606481015b03601f1981018452836103e5565b611ce9565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039283166024820152929091166044830152606482019290925261109891611c008260848101611bf2565b90816020910312610147575180151581036101475790565b15611c7f57565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0316604051611cfe816103c9565b6000806020948584527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656486850152858151910182865af13d15611d9a573d9067ffffffffffffffff82116103c457611d759360405192611d6787601f19601f84011601856103e5565b83523d60008785013e611da3565b80519081611d8257505050565b8261109893611d95938301019101611c60565b611c78565b91611d75926060915b91929015611e045750815115611db7575090565b3b15611dc05790565b606460405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015611e175750805190602001fd5b6118969060405191829162461bcd60e51b83526004830161018c565b90816020910312610147575160ff811681036101475790565b7fff000000000000000000000000000000000000000000000000000000000000008116611f0157602081611e986affffffffffffffffffffff6001600160a01b039460a01c161561129b565b6004604051809481937f313ce567000000000000000000000000000000000000000000000000000000008352165afa90811561171257600091611ed9575090565b61019d915060203d8111611efa575b611ef281836103e5565b810190611e33565b503d611ee8565b7feeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14611f2c57600090565b601290565b91611f529192611f4d8583611f46818561163c565b968461195a565b61163c565b90810390811161063f57106101475756fea26469706673582212206e12eadf160f28b24cbd99639a57f9cfbd43cabb210280eb5e562422fb24e5a164736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001d0188c4b276a09366d05d6be06af61a73bc7535000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde43760000000000000000000000000000000000000000000000000000000000000001
-----Decoded View---------------
Arg [0] : vault_ (address): 0x1d0188c4B276A09366D05d6Be06aF61a73bC7535
Arg [1] : raw_ (bytes32): 0x000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde4376
Arg [2] : allowSkimming_ (bool): True
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000001d0188c4b276a09366d05d6be06af61a73bc7535
Arg [1] : 000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde4376
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000001
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$1,146.58
Net Worth in ETH
Token Allocations
USD+
100.00%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| LINEA | 100.00% | $0.999453 | 1,147.2041 | $1,146.58 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.