Overview
ETH Balance
0.006639922157945897 ETH
ETH Value
$25.73 (@ $3,875.35/ETH)Token Holdings
Could not find any matches!
- ERC-20 Tokens (>100)0.00265556 jEURJarvis Synth... (jEUR)0 aOptDAIAave Optimis... (aOptDA...)$0.00@0.99990.00376939 aOptLINKAave Optimis... (aOptLI...)$0.09@23.774.77582318 aOptOPAave Optimis... (aOptOP)0.12278832 aOptSUSDAave Optimis... (aOptSU...)2.861126 aOptUSDCAave Optimis... (aOptUS...)$2.86@0.99990.006285 aOptUSDTAave Optimis... (aOptUS...)$0.01@1.0010.00006703 aOptWBTCAave Optimis... (aOptWB...)$6.55@97,691.000.00007794 aOptWETHAave Optimis... (aOptWE...)$0.30@3,860.990.0011 ACHIVXACHIVX (ACHIVX)0.203621 axlUSDCAxelar Wrapp... (axlUSD...)$0.20@1.0020.06215685 BALBalancer (BAL)$0.23@3.713.07949947 BOBBOB (BOB)$3.08@1.000.00124416 CELOCelo native ... (CELO)$0.00@1.06450.00097417 LINKChainLink To... (LINK)$0.02@23.880.00000409 cbETHCoinbase Wra... (cbETH)$0.02@4,182.4775.43781956 COLLABCollab.Land (COLLAB)$0.12@0.00161.63565125 DAIDai Stableco... (DAI)$1.64@1.001206 DCNDentacoin (DCN)$0.00@0.000.53966652 DOLADola USD Sta... (DOLA)$0.54@0.99681.61588957 NEXTEverclear (NEXT)$0.23@0.14119.33751068 EXTRAExtra Financ... (EXTRA)$0.89@0.09510.00109346 FRAXFrax (FRAX)$0.00@0.9970.0018507 frxETHFrax Ether (frxETH)$7.13@3,854.760.84206057 GYSRGeyser (GYSR)$0.03@0.037113.71274571 HOPHop (HOP)$0.28@0.02020.00000124 IBIronBank (IB)$0.00@0.88770 JARVISJARVIS (JARVIS)0 JRTJarvis Rewar... (JRT)$0.00@0.00530.00192615 KNCKyber Networ... (KNC)$0.00@0.83561.09237533 ZROLayerZero (ZRO)$7.25@6.641.87780134 LDOLido DAO Tok... (LDO)$4.04@2.159.92694399 LYRALyra Token (LYRA)$0.03@0.002618.33710619 XMTMetalSwap (XMT)$0.24@0.01290.03471368 mooBIFIMoo BIFI (mooBIF...)$13.42@386.460.00403629 O3O3 Swap Toke... (O3)$0.00@0.01330.0000001 tBTCOptimism tBT... (tBTC)$0.01@97,145.000.01081885 PENDLEPendle (PENDLE)$0.07@6.430.68806248 POOLPoolTogether (POOL)$0.75@1.0970.00037457 FIREPromethios (FIRE)$0.00@0.00250.00001716 ezETHRenzo Restak... (ezETH)$0.07@3,963.850.00001349 RPLRocket Pool ... (RPL)$0.00@17.740.00000047 sfrxETHStaked Frax ... (sfrxET...)$0.00@4,259.900.00000001 sBTCSynth sBTC (sBTC)$0.00@78,131.000.00041724 sETHSynth sETH (sETH)$1.60@3,836.4549.94202076 sUSDSynth sUSD (sUSD)$49.88@0.99880.00226671 SNXSynthetix Ne... (SNX)$0.01@3.1114.68562023 TAROTTarot (TAROT)$4.03@0.27427.073445 USDTTether USD (USDT)$7.08@1.00156.26068773 THALESThales DAO T... (THALES)$17.65@0.31380.00641176 TUSDTrueUSD (TUSD)$0.01@0.99878.729714 USDC.eUSD Coin (Br... (USDC.e)$8.73@1.000.949204 USD+USD+ (USD+)$0.95@1.0010 USDeUSDe (USDe)$0.00@1.0035.33362796 VELOVelodrome (VELO)$0.76@0.14188.19824 WLDWorldcoin (WLD)$33.81@4.12350.00042197 WBTCWrapped BTC (WBTC)$41.06@97,313.000.01683365 WETHWrapped Ethe... (WETH)$64.96@3,859.090.00286351 wstETHWrapped liqu... (wstETH)$13.05@4,558.670.00100202 aOptAAVEAave Optimis... (aOptAA...)$0.26@256.7817.76917178 OPOptimism (OP)$45.57@2.56468.516191 USDCUSD Coin (USDC)$8.52@1.0015,000 WLD [ WWW.GET-WLD.ORG ] Visit to claim rewardERC-20: ! (WLD [ ...)0.00031652 0xBTC0xBitcoin Token$0.00@0.11660.05153258 AAVEAave Token$13.32@258.470 ACXAcross Protocol Token$0.00@0.58020 AELINAelin Token0.03237877 agEURagEUR$0.03@1.0578,546,390,651.00171 AIWORLDERC-20: AIWORLD (AIWORL...)0.00005009 ankrETHERC-20: Ankr Stak... (ankrET...)11,080.26197395 AIAny Inu$0.11@0.000.00003753 ASTERC-20: Astrava (AST)0 BONDBarnBridge Governance Token (Optimism)$0.00@1.700.00791108 BeVELOERC-20: Beefy Vel... (BeVELO)0.00213168 BIFIbeefy.finance0 BEETSERC-20: Beethoven... (BEETS)0.00209793 BUSDBinance-Peg BUSD Token$0.00@1.006920.86027243 BNRYBinary Coin$0.92@0.04417,551.17878291 BOOERC-20: Boo Token (BOO)200,000,000,000 opCENERC-20: CEN Crypt... (opCEN)0.03510457 CHIChi USD0.00831082 XCHFERC-20: CryptoFra... (XCHF)1.17731988 CRVCurve DAO Token$1.31@1.111.60285224 CYBERCyberConnect0.09750591 DUSDDavos.xyz USD$0.10@0.99280.29707541 opDXNERC-20: DBXen Tok... (opDXN)3.48234551 USXdForce USD$3.47@0.99716.64064342 DHTdHEDGE DAO Token$1.77@0.10630.00058352 DragonERC-20: Dragon (Dragon)0.01908215 OSERC-20: Ethereans (OS)0.00113584 ENSERC-20: Ethereum ... (ENS)5.86400984 ERNEthos Reserve Note$5.84@0.9960.01955805 EXAexactly$0.01@0.26820 fBOMBFantom Bomb$0.00@0.05950.00000585 frxETHERC-20: Frax Ethe... (frxETH)0.02412773 FUSEFuse Token0.00007315 GTCERC-20: Gitcoin (GTC)160.11100634 GNOMEERC-20: GnomeLand (GNOME)0.00217572 GRAINGranary Token$0.00@0.00441.66087875 HAIHAI Index Token$1.78@1.074NFT Tokens (45)TN1ERC-721TN1ERC-721TN1ERC-721CRS-1­ERC-1155BRTT2­ERC-1155NODE-1­ERC-1155HSH-1­ERC-1155DSTR­ERC-1155VLM-1­ERC-1155DYP-1­ERC-1155RBIT-1­ERC-1155OP-1­ERC-1155BEAM-1­ERC-1155BLNDR-1­ERC-1155PEAPODS Rewards at hexradar.com'ERC-1155nft-aave.com# nft-aave.comERC-1155tw1$100,000 PEIPEIERC-1155tw1$100,000 PEIPEIERC-1155tw1$100,000 SHIBERC-1155tw1$100,000 SHIBERC-1155CRESO Rewards at hexradar.comCRESO COLLECTIONERC-1155Ethereum EventsERC-1155EventERC-1155EventEventERC-1155ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]
More Info
Private Name Tags
ContractCreator
Multichain Info
Latest 8 from a total of 8 transactions
Transaction Hash MethodBlockFromToTransfer* 121997406 2024-06-28 16:53:09 160 days ago 1719593589 IN 0 ETH$0.00 0.000000365379 0.00763489 Transfer* 111368125 2023-10-26 15:43:47 406 days ago 1698335027 IN 0 ETH$0.00 0.000057312349 0.01465566 Transfer* 110384379 2023-10-03 21:12:15 429 days ago 1696367535 IN 0 ETH$0.00 0.000025475826 0.03137687 Transfer* 106242331 2023-06-30 0:03:59 525 days ago 1688083439 IN 0 ETH$0.00 0.00003823868 0.00757733 Transfer* 106225993 2023-06-29 14:59:23 525 days ago 1688050763 IN 0 ETH$0.00 0.000060582046 0.00257225 Transfer* 106225950 2023-06-29 14:57:57 525 days ago 1688050677 IN 0 ETH$0.00 0.000060146501 0.00277208 Transfer* 106225946 2023-06-29 14:57:49 525 days ago 1688050669 IN 0 ETH$0.00 0.000060969035 0.00261226 Transfer* 81209979 2023-03-15 20:15:40 631 days ago 1678911340 IN 0 ETH$0.00 0.000102178452 0.001 Latest 25 internal transactions (View All)
Advanced mode:Parent Transaction Hash Block From To 128898714 2024-12-05 10:56:45 14 hrs ago 1733396205 0.000000324584005 ETH$0.00 128886782 2024-12-05 4:19:01 21 hrs ago 1733372341 0.000000379165757 ETH$0.00 128878386 2024-12-04 23:39:09 25 hrs ago 1733355549 0.000004776704984 ETH$0.02 128873500 2024-12-04 20:56:17 28 hrs ago 1733345777 0.000000000164138 ETH$0.00 128859330 2024-12-04 13:03:57 36 hrs ago 1733317437 0.000001598702991 ETH$0.01 128856657 2024-12-04 11:34:51 37 hrs ago 1733312091 0.000003049784279 ETH$0.01 128834228 2024-12-03 23:07:13 2 days ago 1733267233 0.000004521412065 ETH$0.02 128829440 2024-12-03 20:27:37 2 days ago 1733257657 0.000000002605581 ETH$0.00 128821357 2024-12-03 15:58:11 2 days ago 1733241491 0.000000016541691 ETH$0.00 128796733 2024-12-03 2:17:23 2 days ago 1733192243 0.000000260887302 ETH$0.00 128792041 2024-12-02 23:40:59 3 days ago 1733182859 0.000019755793961 ETH$0.08 128764658 2024-12-02 8:28:13 3 days ago 1733128093 0.000000223039033 ETH$0.00 128755037 2024-12-02 3:07:31 3 days ago 1733108851 0.000000046999844 ETH$0.00 128742862 2024-12-01 20:21:41 4 days ago 1733084501 0.000213377404396 ETH$0.83 128736418 2024-12-01 16:46:53 4 days ago 1733071613 1 wei$0.00 128736019 2024-12-01 16:33:35 4 days ago 1733070815 0.000002947737743 ETH$0.01 128725222 2024-12-01 10:33:41 4 days ago 1733049221 0.000000764639629 ETH$0.00 128711212 2024-12-01 2:46:41 4 days ago 1733021201 0.00000000011352 ETH$0.00 128711090 2024-12-01 2:42:37 4 days ago 1733020957 0.000003436667823 ETH$0.01 128703580 2024-11-30 22:32:17 5 days ago 1733005937 0.000021107390318 ETH$0.08 128703398 2024-11-30 22:26:13 5 days ago 1733005573 0.000000226420863 ETH$0.00 128678541 2024-11-30 8:37:39 5 days ago 1732955859 0.000000097155475 ETH$0.00 128678380 2024-11-30 8:32:17 5 days ago 1732955537 0.000000026378596 ETH$0.00 128663956 2024-11-30 0:31:29 6 days ago 1732926689 0.000000968141317 ETH$0.00 128660034 2024-11-29 22:20:45 6 days ago 1732918845 0.000000003693079 ETH$0.00 Loading...LoadingMinimal Proxy Contract for 0x3e88c9b0e3be6817973a6e629211e702d12c577f
Contract Name:SmartVault
Compiler Versionv0.8.3+commit.8d00100c
Optimization Enabled:Yes with 10000 runs
Other Settings:default evmVersionContract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@openzeppelin/contracts/utils/math/Math.sol'; import '@mimic-fi/v2-bridge-connector/contracts/IBridgeConnector.sol'; import '@mimic-fi/v2-helpers/contracts/math/FixedPoint.sol'; import '@mimic-fi/v2-helpers/contracts/math/UncheckedMath.sol'; import '@mimic-fi/v2-helpers/contracts/utils/Denominations.sol'; import '@mimic-fi/v2-helpers/contracts/utils/IWrappedNativeToken.sol'; import '@mimic-fi/v2-price-oracle/contracts/oracle/IPriceOracle.sol'; import '@mimic-fi/v2-price-oracle/contracts/feeds/PriceFeedProvider.sol'; import '@mimic-fi/v2-strategies/contracts/IStrategy.sol'; import '@mimic-fi/v2-swap-connector/contracts/ISwapConnector.sol'; import '@mimic-fi/v2-registry/contracts/implementations/InitializableAuthorizedImplementation.sol'; import './ISmartVault.sol'; import './helpers/StrategyLib.sol'; import './helpers/SwapConnectorLib.sol'; import './helpers/BridgeConnectorLib.sol'; /** * @title Smart Vault * @dev Smart Vault contract where funds are being held offering a bunch of primitives to allow users model any * type of action to manage them, these are: collector, withdraw, swap, bridge, join, exit, bridge, wrap, and unwrap. * * It inherits from InitializableAuthorizedImplementation which means it's implementation can be cloned * from the Mimic Registry and should be initialized depending on each case. */ contract SmartVault is ISmartVault, PriceFeedProvider, InitializableAuthorizedImplementation { using SafeERC20 for IERC20; using FixedPoint for uint256; using UncheckedMath for uint256; using StrategyLib for address; using SwapConnectorLib for address; using BridgeConnectorLib for address; // Namespace under which the Smart Vault is registered in the Mimic Registry bytes32 public constant override NAMESPACE = keccak256('SMART_VAULT'); /** * @dev Fee configuration parameters * @param pct Percentage expressed using 16 decimals (1e18 = 100%) * @param cap Maximum amount of fees to be charged per period * @param token Address of the token to express the cap amount * @param period Period length in seconds * @param totalCharged Total amount of fees charged in the current period * @param nextResetTime Current cap period end date */ struct Fee { uint256 pct; uint256 cap; address token; uint256 period; uint256 totalCharged; uint256 nextResetTime; } // Price oracle reference address public override priceOracle; // Swap connector reference address public override swapConnector; // Bridge connector reference address public override bridgeConnector; // List of allowed strategies indexed by strategy address mapping (address => bool) public override isStrategyAllowed; // List of invested values indexed by strategy address mapping (address => uint256) public override investedValue; // Fee collector address where fees will be deposited address public override feeCollector; // Withdraw fee configuration Fee public override withdrawFee; // Performance fee configuration Fee public override performanceFee; // Swap fee configuration Fee public override swapFee; // Bridge fee configuration Fee public override bridgeFee; // Wrapped native token reference address public immutable override wrappedNativeToken; /** * @dev Creates a new Smart Vault implementation with references that should be shared among all implementations * @param _wrappedNativeToken Address of the wrapped native token to be used * @param _registry Address of the Mimic Registry to be referenced */ constructor(address _wrappedNativeToken, address _registry) InitializableAuthorizedImplementation(_registry) { wrappedNativeToken = _wrappedNativeToken; } /** * @dev Initializes the Smart Vault instance * @param admin Address that will be granted with admin rights */ function initialize(address admin) external initializer { _initialize(admin); } /** * @dev It allows receiving native token transfers */ receive() external payable { // solhint-disable-previous-line no-empty-blocks } /** * @dev Sets a new strategy as allowed or not for a Smart Vault. Sender must be authorized. * @param strategy Address of the strategy to be set * @param allowed Whether the strategy is allowed or not */ function setStrategy(address strategy, bool allowed) external override auth { _setStrategy(strategy, allowed); } /** * @dev Sets a new price oracle to a Smart Vault. Sender must be authorized. * @param newPriceOracle Address of the new price oracle to be set */ function setPriceOracle(address newPriceOracle) external override auth { _setPriceOracle(newPriceOracle); } /** * @dev Sets a new swap connector to a Smart Vault. Sender must be authorized. * @param newSwapConnector Address of the new swap connector to be set */ function setSwapConnector(address newSwapConnector) external override auth { _setSwapConnector(newSwapConnector); } /** * @dev Sets a new bridge connector to a Smart Vault. Sender must be authorized. * @param newBridgeConnector Address of the new bridge connector to be set */ function setBridgeConnector(address newBridgeConnector) external override auth { _setBridgeConnector(newBridgeConnector); } /** * @dev Sets a new fee collector. Sender must be authorized. * @param newFeeCollector Address of the new fee collector to be set */ function setFeeCollector(address newFeeCollector) external override auth { _setFeeCollector(newFeeCollector); } /** * @dev Sets a new withdraw fee. Sender must be authorized. * @param pct Withdraw fee percentage to be set * @param cap New maximum amount of withdraw fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the withdraw fee */ function setWithdrawFee(uint256 pct, uint256 cap, address token, uint256 period) external override auth { _setFeeConfiguration(withdrawFee, pct, cap, token, period); emit WithdrawFeeSet(pct, cap, token, period); } /** * @dev Sets a new performance fee. Sender must be authorized. * @param pct Performance fee percentage to be set * @param cap New maximum amount of performance fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the performance fee */ function setPerformanceFee(uint256 pct, uint256 cap, address token, uint256 period) external override auth { _setFeeConfiguration(performanceFee, pct, cap, token, period); emit PerformanceFeeSet(pct, cap, token, period); } /** * @dev Sets a new swap fee. Sender must be authorized. * @param pct New swap fee percentage to be set * @param cap New maximum amount of swap fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the swap fee */ function setSwapFee(uint256 pct, uint256 cap, address token, uint256 period) external override auth { _setFeeConfiguration(swapFee, pct, cap, token, period); emit SwapFeeSet(pct, cap, token, period); } /** * @dev Sets a new bridge fee. Sender must be authorized. * @param pct New bridge fee percentage to be set * @param cap New maximum amount of bridge fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the bridge fee */ function setBridgeFee(uint256 pct, uint256 cap, address token, uint256 period) external override auth { _setFeeConfiguration(bridgeFee, pct, cap, token, period); emit BridgeFeeSet(pct, cap, token, period); } /** * @dev Sets a of price feed * @param base Token base to be set * @param quote Token quote to be set * @param feed Price feed to be set */ function setPriceFeed(address base, address quote, address feed) public override(IPriceFeedProvider, PriceFeedProvider) auth { super.setPriceFeed(base, quote, feed); } /** * @dev Tells the price of a token (base) in a given quote * @param base Token to rate * @param quote Token used for the price rate */ function getPrice(address base, address quote) public view override returns (uint256) { return IPriceOracle(priceOracle).getPrice(address(this), base, quote); } /** * @dev Tells the last value accrued for a strategy. Note this value can be outdated. * @param strategy Address of the strategy querying the last value of */ function lastValue(address strategy) public view override returns (uint256) { return IStrategy(strategy).lastValue(address(this)); } /** * @dev Execute an arbitrary call from a Smart Vault. Sender must be authorized. * @param target Address where the call will be sent * @param data Calldata to be used for the call * @param value Value in wei that will be attached to the call * @return result Call response if it was successful, otherwise it reverts */ function call(address target, bytes memory callData, uint256 value, bytes memory data) external override auth returns (bytes memory result) { result = Address.functionCallWithValue(target, callData, value, 'SMART_VAULT_ARBITRARY_CALL_FAIL'); emit Call(target, callData, value, result, data); } /** * @dev Collect tokens from an external account to a Smart Vault. Sender must be authorized. * @param token Address of the token to be collected * @param from Address where the tokens will be transfer from * @param amount Amount of tokens to be transferred * @param data Extra data only logged * @return collected Amount of tokens collected */ function collect(address token, address from, uint256 amount, bytes memory data) external override auth returns (uint256 collected) { require(amount > 0, 'COLLECT_AMOUNT_ZERO'); uint256 previousBalance = IERC20(token).balanceOf(address(this)); IERC20(token).safeTransferFrom(from, address(this), amount); uint256 currentBalance = IERC20(token).balanceOf(address(this)); collected = currentBalance - previousBalance; emit Collect(token, from, collected, data); } /** * @dev Withdraw tokens to an external account. Sender must be authorized. * @param token Address of the token to be withdrawn * @param amount Amount of tokens to withdraw * @param recipient Address where the tokens will be transferred to * @param data Extra data only logged * @return withdrawn Amount of tokens transferred to the recipient address */ function withdraw(address token, uint256 amount, address recipient, bytes memory data) external override auth returns (uint256 withdrawn) { require(amount > 0, 'WITHDRAW_AMOUNT_ZERO'); require(recipient != address(0), 'RECIPIENT_ZERO'); uint256 withdrawFeeAmount = recipient == feeCollector ? 0 : _payFee(token, amount, withdrawFee); withdrawn = amount - withdrawFeeAmount; _safeTransfer(token, recipient, withdrawn); emit Withdraw(token, recipient, withdrawn, withdrawFeeAmount, data); } /** * @dev Wrap an amount of native tokens to the wrapped ERC20 version of it. Sender must be authorized. * @param amount Amount of native tokens to be wrapped * @param data Extra data only logged * @return wrapped Amount of tokens wrapped */ function wrap(uint256 amount, bytes memory data) external override auth returns (uint256 wrapped) { require(amount > 0, 'WRAP_AMOUNT_ZERO'); require(address(this).balance >= amount, 'WRAP_INSUFFICIENT_AMOUNT'); IWrappedNativeToken wrappedToken = IWrappedNativeToken(wrappedNativeToken); uint256 previousBalance = wrappedToken.balanceOf(address(this)); wrappedToken.deposit{ value: amount }(); uint256 currentBalance = wrappedToken.balanceOf(address(this)); wrapped = currentBalance - previousBalance; emit Wrap(amount, wrapped, data); } /** * @dev Unwrap an amount of wrapped native tokens. Sender must be authorized. * @param amount Amount of wrapped native tokens to unwrapped * @param data Extra data only logged * @return unwrapped Amount of tokens unwrapped */ function unwrap(uint256 amount, bytes memory data) external override auth returns (uint256 unwrapped) { require(amount > 0, 'UNWRAP_AMOUNT_ZERO'); uint256 previousBalance = address(this).balance; IWrappedNativeToken(wrappedNativeToken).withdraw(amount); uint256 currentBalance = address(this).balance; unwrapped = currentBalance - previousBalance; emit Unwrap(amount, unwrapped, data); } /** * @dev Claim strategy rewards. Sender must be authorized. * @param strategy Address of the strategy to claim rewards * @param data Extra data passed to the strategy and logged * @return tokens Addresses of the tokens received as rewards * @return amounts Amounts of the tokens received as rewards */ function claim(address strategy, bytes memory data) external override auth returns (address[] memory tokens, uint256[] memory amounts) { require(isStrategyAllowed[strategy], 'STRATEGY_NOT_ALLOWED'); (tokens, amounts) = strategy.claim(data); emit Claim(strategy, tokens, amounts, data); } /** * @dev Join a strategy with an amount of tokens. Sender must be authorized. * @param strategy Address of the strategy to join * @param tokensIn List of token addresses to join with * @param amountsIn List of token amounts to join with * @param slippage Slippage that will be used to compute the join * @param data Extra data passed to the strategy and logged * @return tokensOut List of token addresses received after the join * @return amountsOut List of token amounts received after the join */ function join( address strategy, address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data ) external override auth returns (address[] memory tokensOut, uint256[] memory amountsOut) { require(isStrategyAllowed[strategy], 'STRATEGY_NOT_ALLOWED'); require(slippage <= FixedPoint.ONE, 'JOIN_SLIPPAGE_ABOVE_ONE'); require(tokensIn.length == amountsIn.length, 'JOIN_INPUT_INVALID_LENGTH'); uint256 value; (tokensOut, amountsOut, value) = strategy.join(tokensIn, amountsIn, slippage, data); require(tokensOut.length == amountsOut.length, 'JOIN_OUTPUT_INVALID_LENGTH'); investedValue[strategy] = investedValue[strategy] + value; emit Join(strategy, tokensIn, amountsIn, tokensOut, amountsOut, value, slippage, data); } /** * @dev Exit a strategy. Sender must be authorized. * @param strategy Address of the strategy to exit * @param tokensIn List of token addresses to exit with * @param amountsIn List of token amounts to exit with * @param slippage Slippage that will be used to compute the exit * @param data Extra data passed to the strategy and logged * @return tokensOut List of token addresses received after the exit * @return amountsOut List of token amounts received after the exit */ function exit( address strategy, address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data ) external override auth returns (address[] memory tokensOut, uint256[] memory amountsOut) { require(isStrategyAllowed[strategy], 'STRATEGY_NOT_ALLOWED'); require(investedValue[strategy] > 0, 'EXIT_NO_INVESTED_VALUE'); require(slippage <= FixedPoint.ONE, 'EXIT_SLIPPAGE_ABOVE_ONE'); require(tokensIn.length == amountsIn.length, 'EXIT_INPUT_INVALID_LENGTH'); uint256 value; (tokensOut, amountsOut, value) = strategy.exit(tokensIn, amountsIn, slippage, data); require(tokensOut.length == amountsOut.length, 'EXIT_OUTPUT_INVALID_LENGTH'); uint256[] memory performanceFeeAmounts = new uint256[](amountsOut.length); // It can rely on the last updated value since we have just exited, no need to compute current value uint256 valueBeforeExit = lastValue(strategy) + value; if (valueBeforeExit <= investedValue[strategy]) { // There were losses, invested value is simply reduced using the exited ratio compared to the value // before exit. Invested value is round up to avoid interpreting losses due to rounding errors investedValue[strategy] -= investedValue[strategy].mulUp(value).divUp(valueBeforeExit); } else { // If value gains are greater than the exit value, it means only gains are being withdrawn. In that case // the taxable amount is the entire exited amount, otherwise it should be the equivalent gains ratio of it. uint256 valueGains = valueBeforeExit.uncheckedSub(investedValue[strategy]); bool onlyGains = valueGains >= value; // If the exit value is greater than the value gains, the invested value should be reduced by the portion // of the invested value being exited. Otherwise, it's still the same, only gains are being withdrawn. // No need for checked math as we are checking it manually beforehand uint256 decrement = onlyGains ? 0 : value.uncheckedSub(valueGains); investedValue[strategy] = investedValue[strategy] - decrement; // Compute performance fees per token out for (uint256 i = 0; i < tokensOut.length; i = i.uncheckedAdd(1)) { address token = tokensOut[i]; uint256 amount = amountsOut[i]; uint256 taxableAmount = onlyGains ? amount : ((amount * valueGains) / value); uint256 feeAmount = _payFee(token, taxableAmount, performanceFee); amountsOut[i] = amount - feeAmount; performanceFeeAmounts[i] = feeAmount; } } emit Exit(strategy, tokensIn, amountsIn, tokensOut, amountsOut, value, performanceFeeAmounts, slippage, data); } /** * @dev Swaps two tokens. Sender must be authorized. * @param source Source to request the swap: Uniswap V2, Uniswap V3, Balancer V2, or Paraswap V5. * @param tokenIn Token being sent * @param tokenOut Token being received * @param amountIn Amount of tokenIn being swapped * @param limitType Swap limit to be applied: slippage or min amount out * @param limitAmount Amount of the swap limit to be applied depending on limitType * @param data Encoded data to specify different swap parameters depending on the source picked * @return amountOut Received amount of tokens out */ function swap( uint8 source, address tokenIn, address tokenOut, uint256 amountIn, SwapLimit limitType, uint256 limitAmount, bytes memory data ) external override auth returns (uint256 amountOut) { require(tokenIn != tokenOut, 'SWAP_SAME_TOKEN'); require(swapConnector != address(0), 'SWAP_CONNECTOR_NOT_SET'); uint256 minAmountOut; if (limitType == SwapLimit.MinAmountOut) { minAmountOut = limitAmount; } else if (limitType == SwapLimit.Slippage) { require(limitAmount <= FixedPoint.ONE, 'SWAP_SLIPPAGE_ABOVE_ONE'); uint256 price = getPrice(tokenIn, tokenOut); // No need for checked math as we are checking it manually beforehand // Always round up the expected min amount out. Limit amount is slippage. minAmountOut = amountIn.mulUp(price).mulUp(FixedPoint.ONE.uncheckedSub(limitAmount)); } else { revert('SWAP_INVALID_LIMIT_TYPE'); } uint256 preBalanceIn = IERC20(tokenIn).balanceOf(address(this)); uint256 preBalanceOut = IERC20(tokenOut).balanceOf(address(this)); swapConnector.swap(source, tokenIn, tokenOut, amountIn, minAmountOut, data); uint256 postBalanceIn = IERC20(tokenIn).balanceOf(address(this)); require(postBalanceIn >= preBalanceIn - amountIn, 'SWAP_BAD_TOKEN_IN_BALANCE'); uint256 amountOutBeforeFees = IERC20(tokenOut).balanceOf(address(this)) - preBalanceOut; require(amountOutBeforeFees >= minAmountOut, 'SWAP_MIN_AMOUNT'); uint256 swapFeeAmount = _payFee(tokenOut, amountOutBeforeFees, swapFee); amountOut = amountOutBeforeFees - swapFeeAmount; emit Swap(source, tokenIn, tokenOut, amountIn, amountOut, minAmountOut, swapFeeAmount, data); } /** * @dev Bridge assets to another chain * @param source Source to request the bridge. It depends on the Bridge Connector attached to a Smart Vault. * @param chainId ID of the destination chain * @param token Address of the token to be bridged * @param amount Amount of tokens to be bridged * @param limitType Bridge limit to be applied: slippage or min amount out * @param limitAmount Amount of the swap limit to be applied depending on limitType * @param recipient Address that will receive the tokens on the destination chain * @param data Encoded data to specify different bridge parameters depending on the source picked * @return bridged Amount requested to be bridged after fees */ function bridge( uint8 source, uint256 chainId, address token, uint256 amount, BridgeLimit limitType, uint256 limitAmount, address recipient, bytes memory data ) external override auth returns (uint256 bridged) { require(block.chainid != chainId, 'BRIDGE_SAME_CHAIN'); require(recipient != address(0), 'BRIDGE_RECIPIENT_ZERO'); require(bridgeConnector != address(0), 'BRIDGE_CONNECTOR_NOT_SET'); uint256 bridgeFeeAmount = _payFee(token, amount, bridgeFee); bridged = amount - bridgeFeeAmount; uint256 minAmountOut; if (limitType == BridgeLimit.MinAmountOut) { minAmountOut = limitAmount; } else if (limitType == BridgeLimit.Slippage) { require(limitAmount <= FixedPoint.ONE, 'BRIDGE_SLIPPAGE_ABOVE_ONE'); // No need for checked math as we are checking it manually beforehand // Always round up the expected min amount out. Limit amount is slippage. minAmountOut = bridged.mulUp(FixedPoint.ONE.uncheckedSub(limitAmount)); } else { revert('BRIDGE_INVALID_LIMIT_TYPE'); } uint256 preBalanceIn = IERC20(token).balanceOf(address(this)); bridgeConnector.bridge(source, chainId, token, bridged, minAmountOut, recipient, data); uint256 postBalanceIn = IERC20(token).balanceOf(address(this)); require(postBalanceIn >= preBalanceIn - bridged, 'BRIDGE_BAD_TOKEN_IN_BALANCE'); emit Bridge(source, chainId, token, bridged, minAmountOut, bridgeFeeAmount, recipient, data); } /** * @dev Internal function to pay the amount of fees to be charged based on a fee configuration to the fee collector * @param token Token being charged * @param amount Token amount to be taxed with fees * @param fee Fee configuration to be applied * @return paidAmount Amount of fees paid to the fee collector */ function _payFee(address token, uint256 amount, Fee storage fee) internal returns (uint256 paidAmount) { // Fee amounts are always rounded down uint256 feeAmount = amount.mulDown(fee.pct); // If cap amount or cap period are not set, charge the entire amount if (fee.token == address(0) || fee.cap == 0 || fee.period == 0) { _safeTransfer(token, feeCollector, feeAmount); return feeAmount; } // Reset cap totalizator if necessary if (block.timestamp >= fee.nextResetTime) { fee.totalCharged = 0; fee.nextResetTime = block.timestamp + fee.period; } // Calc fee amount in the fee token used for the cap uint256 feeTokenPrice = getPrice(token, fee.token); uint256 feeAmountInFeeToken = feeAmount.mulDown(feeTokenPrice); // Compute fee amount picking the minimum between the chargeable amount and the remaining part for the cap if (fee.totalCharged + feeAmountInFeeToken <= fee.cap) { paidAmount = feeAmount; fee.totalCharged += feeAmountInFeeToken; } else if (fee.totalCharged < fee.cap) { paidAmount = (fee.cap.uncheckedSub(fee.totalCharged) * feeAmount) / feeAmountInFeeToken; fee.totalCharged = fee.cap; } else { // This case is when the total charged amount is already greater than the cap amount. It could happen if // the cap amounts is decreased or if the cap token is changed. In this case the total charged amount is // not updated, and the amount to paid is zero. paidAmount = 0; } // Pay fee amount to the fee collector _safeTransfer(token, feeCollector, paidAmount); } /** * @dev Internal method to transfer ERC20 or native tokens from a Smart Vault * @param token Address of the ERC20 token to transfer * @param to Address transferring the tokens to * @param amount Amount of tokens to transfer */ function _safeTransfer(address token, address to, uint256 amount) internal { if (amount == 0) return; if (Denominations.isNativeToken(token)) Address.sendValue(payable(to), amount); else IERC20(token).safeTransfer(to, amount); } /** * @dev Sets a new strategy as allowed or not * @param strategy Address of the strategy to be set * @param allowed Whether the strategy is allowed or not */ function _setStrategy(address strategy, bool allowed) internal { if (allowed) _validateStatelessDependency(strategy); isStrategyAllowed[strategy] = allowed; emit StrategySet(strategy, allowed); } /** * @dev Sets a new price oracle * @param newPriceOracle New price oracle to be set */ function _setPriceOracle(address newPriceOracle) internal { _validateStatelessDependency(newPriceOracle); priceOracle = newPriceOracle; emit PriceOracleSet(newPriceOracle); } /** * @dev Sets a new swap connector * @param newSwapConnector New swap connector to be set */ function _setSwapConnector(address newSwapConnector) internal { _validateStatelessDependency(newSwapConnector); swapConnector = newSwapConnector; emit SwapConnectorSet(newSwapConnector); } /** * @dev Sets a new bridge connector * @param newBridgeConnector New bridge connector to be set */ function _setBridgeConnector(address newBridgeConnector) internal { _validateStatelessDependency(newBridgeConnector); bridgeConnector = newBridgeConnector; emit BridgeConnectorSet(newBridgeConnector); } /** * @dev Internal method to set the fee collector * @param newFeeCollector New fee collector to be set */ function _setFeeCollector(address newFeeCollector) internal { require(newFeeCollector != address(0), 'FEE_COLLECTOR_ZERO'); feeCollector = newFeeCollector; emit FeeCollectorSet(newFeeCollector); } /** * @dev Internal method to set a new fee cap configuration * @param fee Fee configuration to be updated * @param pct Fee percentage to be set * @param cap New maximum amount of fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds */ function _setFeeConfiguration(Fee storage fee, uint256 pct, uint256 cap, address token, uint256 period) internal { require(pct <= FixedPoint.ONE, 'FEE_PCT_ABOVE_ONE'); // If there is no fee percentage, there must not be a fee cap bool isZeroCap = token == address(0) && cap == 0 && period == 0; require(pct != 0 || isZeroCap, 'INVALID_CAP_WITH_FEE_ZERO'); // If there is a cap, all values must be non-zero bool isNonZeroCap = token != address(0) && cap != 0 && period != 0; require(isZeroCap || isNonZeroCap, 'INCONSISTENT_CAP_VALUES'); // Changing the fee percentage does not affect the totalizator at all, it only affects future fee charges fee.pct = pct; // Changing the fee cap amount does not affect the totalizator, it only applies when changing the for the total // charged amount. Note that it can happen that the cap amount is lower than the total charged amount if the // cap amount is lowered. However, there shouldn't be any accounting issues with that. fee.cap = cap; // Changing the cap period only affects the end time of the next period, but not the end date of the current one fee.period = period; // Therefore, only clean the totalizators if the cap is being removed if (isZeroCap) { fee.totalCharged = 0; fee.nextResetTime = 0; } else { // If cap values are not zero, set the next reset time if it wasn't set already // Otherwise, if the cap token is being changed the total charged amount must be updated accordingly if (fee.nextResetTime == 0) { fee.nextResetTime = block.timestamp + period; } else if (fee.token != token) { uint256 newTokenPrice = getPrice(fee.token, token); fee.totalCharged = fee.totalCharged.mulDown(newTokenPrice); } } // Finally simply set the new requested token fee.token = token; } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-registry/contracts/implementations/IImplementation.sol'; /** * @title IBridgeConnector * @dev Bridge Connector interface to bridge tokens between different chains. It must follow IImplementation interface. */ interface IBridgeConnector is IImplementation { /** * @dev Enum identifying the sources proposed: Hop only for now. */ enum Source { Hop } /** * @dev Bridge assets to a different chain * @param source Source to execute the requested bridge op * @param chainId ID of the destination chain * @param token Address of the token to be bridged * @param amountIn Amount of tokens to be bridged * @param minAmountOut Minimum amount of tokens willing to receive on the destination chain * @param recipient Address that will receive the tokens on the destination chain * @param data ABI encoded data that will depend on the requested source */ function bridge( uint8 source, uint256 chainId, address token, uint256 amountIn, uint256 minAmountOut, address recipient, bytes memory data ) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import './IAuthorizer.sol'; /** * @title Authorizer * @dev Authorization module to be used by contracts that need to implement permissions for their methods. * It provides a permissions model to list who is allowed to call what function in a contract. And only accounts * authorized to manage those permissions are the ones that are allowed to authorize or unauthorize accounts. */ contract Authorizer is IAuthorizer { // Constant used to denote that a permission is open to anyone address public constant ANY_ADDRESS = address(0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF); // Internal mapping to tell who is allowed to do what indexed by (account, function selector) mapping (address => mapping (bytes4 => bool)) private authorized; /** * @dev Modifier that should be used to tag protected functions */ modifier auth() { _authenticate(msg.sender, msg.sig); _; } /** * @dev Tells whether someone is allowed to call a function or not. It returns true if it's allowed to anyone. * @param who Address asking permission for * @param what Function selector asking permission for */ function isAuthorized(address who, bytes4 what) public view override returns (bool) { return authorized[ANY_ADDRESS][what] || authorized[who][what]; } /** * @dev Authorizes someone to call a function. Sender must be authorize to do so. * @param who Address to be authorized * @param what Function selector to be granted */ function authorize(address who, bytes4 what) external override auth { _authorize(who, what); } /** * @dev Unauthorizes someone to call a function. Sender must be authorize to do so. * @param who Address to be unauthorized * @param what Function selector to be revoked */ function unauthorize(address who, bytes4 what) external override auth { _unauthorize(who, what); } /** * @dev Internal function to authenticate someone over a function. * It reverts if the given account is not authorized to call the requested function. * @param who Address to be authenticated * @param what Function selector to be authenticated */ function _authenticate(address who, bytes4 what) internal view { require(isAuthorized(who, what), 'AUTH_SENDER_NOT_ALLOWED'); } /** * @dev Internal function to authorize someone to call a function * @param who Address to be authorized * @param what Function selector to be granted */ function _authorize(address who, bytes4 what) internal { authorized[who][what] = true; emit Authorized(who, what); } /** * @dev Internal function to unauthorize someone to call a function * @param who Address to be unauthorized * @param what Function selector to be revoked */ function _unauthorize(address who, bytes4 what) internal { authorized[who][what] = false; emit Unauthorized(who, what); } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; /** * @title IAuthorizer */ interface IAuthorizer { /** * @dev Emitted when an account is authorized to call a function */ event Authorized(address indexed who, bytes4 what); /** * @dev Emitted when an account is unauthorized to call a function */ event Unauthorized(address indexed who, bytes4 what); /** * @dev Authorizes someone to call a function. Sender must be authorize to do so. * @param who Address to be authorized * @param what Function selector to be granted */ function authorize(address who, bytes4 what) external; /** * @dev Unauthorizes someone to call a function. Sender must be authorize to do so. * @param who Address to be unauthorized * @param what Function selector to be revoked */ function unauthorize(address who, bytes4 what) external; /** * @dev Tells whether someone is allowed to call a function or not. It returns true if it's allowed to anyone. * @param who Address asking permission for * @param what Function selector asking permission for */ function isAuthorized(address who, bytes4 what) external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; /** * @title FixedPoint * @dev Math library to operate with fixed point values with 18 decimals */ library FixedPoint { // 1 in fixed point value: 18 decimal places uint256 internal constant ONE = 1e18; /** * @dev Multiplies two fixed point numbers rounding down */ function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { uint256 product = a * b; require(a == 0 || product / a == b, 'MUL_OVERFLOW'); return product / ONE; } } /** * @dev Multiplies two fixed point numbers rounding up */ function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { uint256 product = a * b; require(a == 0 || product / a == b, 'MUL_OVERFLOW'); return product == 0 ? 0 : (((product - 1) / ONE) + 1); } } /** * @dev Divides two fixed point numbers rounding down */ function divDown(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { require(b != 0, 'ZERO_DIVISION'); if (a == 0) return 0; uint256 aInflated = a * ONE; require(aInflated / a == ONE, 'DIV_INTERNAL'); return aInflated / b; } } /** * @dev Divides two fixed point numbers rounding up */ function divUp(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { require(b != 0, 'ZERO_DIVISION'); if (a == 0) return 0; uint256 aInflated = a * ONE; require(aInflated / a == ONE, 'DIV_INTERNAL'); return ((aInflated - 1) / b) + 1; } } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; /** * @title UncheckedMath * @dev Math library to perform unchecked operations */ library UncheckedMath { /** * @dev Unsafely adds two unsigned integers */ function uncheckedAdd(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { return a + b; } } /** * @dev Unsafely subtracts two unsigned integers */ function uncheckedSub(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { return a - b; } } /** * @dev Unsafely multiplies two unsigned integers */ function uncheckedMul(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { return a * b; } } /** * @dev Unsafely multiplies two signed integers */ function uncheckedMul(int256 a, int256 b) internal pure returns (int256) { unchecked { return a * b; } } /** * @dev Unsafely divides two unsigned integers */ function uncheckedDiv(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { return a / b; } } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; /** * @title Denominations * @dev Provides a list of ground denominations for those tokens that cannot be represented by an ERC20. * For now, the only needed is the native token that could be ETH, MATIC, or other depending on the layer being operated. */ library Denominations { address internal constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; function isNativeToken(address token) internal pure returns (bool) { return token == NATIVE_TOKEN; } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /** * @title IWrappedNativeToken */ interface IWrappedNativeToken is IERC20 { /** * @dev Wraps msg.value into the wrapped-native token */ function deposit() external payable; /** * @dev Unwraps requested amount to the native token */ function withdraw(uint256 amount) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; /** * @title IPriceFeedProvider * @dev Contract providing price feed references for (base, quote) token pairs */ interface IPriceFeedProvider { /** * @dev Emitted every time a price feed is set for (base, quote) pair */ event PriceFeedSet(address indexed base, address indexed quote, address feed); /** * @dev Tells the price feed address for (base, quote) pair. It returns the zero address if there is no one set. * @param base Token to be rated * @param quote Token used for the price rate */ function getPriceFeed(address base, address quote) external view returns (address); /** * @dev Sets a of price feed * @param base Token base to be set * @param quote Token quote to be set * @param feed Price feed to be set */ function setPriceFeed(address base, address quote, address feed) external; /** * @dev Sets a list of price feeds * @param bases List of token bases to be set * @param quotes List of token quotes to be set * @param feeds List of price feeds to be set */ function setPriceFeeds(address[] memory bases, address[] memory quotes, address[] memory feeds) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-helpers/contracts/math/UncheckedMath.sol'; import './IPriceFeedProvider.sol'; /** * @title IPriceFeedProvider * @dev Contract providing price feed references for (base, quote) token pairs */ contract PriceFeedProvider is IPriceFeedProvider { using UncheckedMath for uint256; // Mapping of price feeds from "token A" to "token B" mapping (address => mapping (address => address)) private _priceFeeds; /** * @dev Tells the price feed address for (base, quote) pair. It returns the zero address if there is no one set. * @param base Token to be rated * @param quote Token used for the price rate */ function getPriceFeed(address base, address quote) external view override returns (address) { return _priceFeeds[base][quote]; } /** * @dev Sets a of price feed * @param base Token base to be set * @param quote Token quote to be set * @param feed Price feed to be set */ function setPriceFeed(address base, address quote, address feed) public virtual override { _priceFeeds[base][quote] = feed; emit PriceFeedSet(base, quote, feed); } /** * @dev Sets a list of price feeds. Sender must be authorized. * @param bases List of token bases to be set * @param quotes List of token quotes to be set * @param feeds List of price feeds to be set */ function setPriceFeeds(address[] memory bases, address[] memory quotes, address[] memory feeds) public virtual override { require(bases.length == quotes.length, 'SET_FEEDS_INVALID_QUOTES_LENGTH'); require(bases.length == feeds.length, 'SET_FEEDS_INVALID_FEEDS_LENGTH'); for (uint256 i = 0; i < bases.length; i = i.uncheckedAdd(1)) setPriceFeed(bases[i], quotes[i], feeds[i]); } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-registry/contracts/implementations/IImplementation.sol'; /** * @title IPriceOracle * @dev Oracle that interfaces with external feeds to provide quotes for tokens based on any other token. * It must support also `IImplementation`. */ interface IPriceOracle is IImplementation { /** * @dev Tells the price of a token (base) in a given quote. The response is expressed using the corresponding * number of decimals so that when performing a fixed point product of it by a `base` amount it results in * a value expressed in `quote` decimals. For example, if `base` is ETH and `quote` is USDC, then the returned * value is expected to be expressed using 6 decimals: * * FixedPoint.mul(X[ETH], price[USDC/ETH]) = FixedPoint.mul(X[18], price[6]) = X * price [6] * * @param provider Contract providing the price feeds to use by the oracle * @param base Token to rate * @param quote Token used for the price rate */ function getPrice(address provider, address base, address quote) external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/proxy/utils/Initializable.sol'; import './IImplementation.sol'; import '../registry/IRegistry.sol'; /** * @title BaseImplementation * @dev This implementation contract comes with an immutable reference to an implementations registry where it should * be registered as well (checked during initialization). It allows requesting new instances of other registered * implementations to as another safety check to make sure valid instances are referenced in case it's needed. */ abstract contract BaseImplementation is IImplementation { // Immutable implementations registry reference address public immutable override registry; /** * @dev Creates a new BaseImplementation * @param _registry Address of the Mimic Registry where dependencies will be validated against */ constructor(address _registry) { registry = _registry; } /** * @dev Internal function to validate a new dependency that must be registered as stateless. * It checks the new dependency is registered, not deprecated, and stateless. * @param dependency New stateless dependency to be set */ function _validateStatelessDependency(address dependency) internal view { require(_validateDependency(dependency), 'DEPENDENCY_NOT_STATELESS'); } /** * @dev Internal function to validate a new dependency that cannot be registered as stateless. * It checks the new dependency is registered, not deprecated, and not stateful. * @param dependency New stateful dependency to be set */ function _validateStatefulDependency(address dependency) internal view { require(!_validateDependency(dependency), 'DEPENDENCY_NOT_STATEFUL'); } /** * @dev Internal function to validate a new dependency. It checks the dependency is registered and not deprecated. * @param dependency New dependency to be set * @return Whether the dependency is stateless or not */ function _validateDependency(address dependency) private view returns (bool) { (bool stateless, bool deprecated, bytes32 namespace) = IRegistry(registry).implementationData(dependency); require(namespace != bytes32(0), 'DEPENDENCY_NOT_REGISTERED'); require(!deprecated, 'DEPENDENCY_DEPRECATED'); return stateless; } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; // solhint-disable func-name-mixedcase /** * @title IImplementation * @dev Implementation interface that must be followed for implementations to be registered in the Mimic Registry */ interface IImplementation { /** * @dev Tells the namespace under which the implementation is registered in the Mimic Registry */ function NAMESPACE() external view returns (bytes32); /** * @dev Tells the address of the Mimic Registry */ function registry() external view returns (address); }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-helpers/contracts/auth/Authorizer.sol'; import './InitializableImplementation.sol'; /** * @title InitializableAuthorizedImplementation * @dev InitializableImplementation using the Authorizer mixin. Initializable implementations that want to use the * Authorizer permissions mechanism should inherit from this contract instead. */ abstract contract InitializableAuthorizedImplementation is InitializableImplementation, Authorizer { /** * @dev Creates a new InitializableAuthorizedImplementation * @param registry Address of the Mimic Registry */ constructor(address registry) InitializableImplementation(registry) { // solhint-disable-previous-line no-empty-blocks } /** * @dev Initialization function that authorizes an admin account to authorize and unauthorize accounts. * Note this function can only be called from a function marked with the `initializer` modifier. * @param admin Address to be granted authorize and unauthorize permissions */ function _initialize(address admin) internal onlyInitializing { _initialize(); _authorize(admin, Authorizer.authorize.selector); _authorize(admin, Authorizer.unauthorize.selector); } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/proxy/utils/Initializable.sol'; import './BaseImplementation.sol'; /** * @title InitializableImplementation * @dev Implementation contract to be used through proxies. Inheriting contracts are meant to be initialized through * initialization functions instead of constructor functions. It allows re-using the same logic contract while making * deployments cheaper. */ abstract contract InitializableImplementation is BaseImplementation, Initializable { /** * @dev Creates a new BaseImplementation. Note that initializers are disabled at creation time. */ constructor(address registry) BaseImplementation(registry) { _disableInitializers(); } /** * @dev Initialization function. * Note this function can only be called from a function marked with the `initializer` modifier. */ function _initialize() internal view onlyInitializing { // solhint-disable-previous-line no-empty-blocks } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-helpers/contracts/auth/IAuthorizer.sol'; /** * @title IRegistry * @dev Registry interface, it must follow the IAuthorizer interface. */ interface IRegistry is IAuthorizer { /** * @dev Emitted every time a new implementation is registered */ event Registered(bytes32 indexed namespace, address indexed implementation, bool stateless); /** * @dev Emitted every time an implementation is deprecated */ event Deprecated(bytes32 indexed namespace, address indexed implementation); /** * @dev Tells the data of an implementation: * @param implementation Address of the implementation to request it's data */ function implementationData(address implementation) external view returns (bool stateless, bool deprecated, bytes32 namespace); /** * @dev Tells if a specific implementation is registered under a certain namespace and it's not deprecated * @param namespace Namespace asking for * @param implementation Address of the implementation to be checked */ function isActive(bytes32 namespace, address implementation) external view returns (bool); /** * @dev Registers a new implementation for a given namespace * @param namespace Namespace to be used for the implementation * @param implementation Address of the implementation to be registered * @param stateless Whether the implementation is stateless or not */ function register(bytes32 namespace, address implementation, bool stateless) external; /** * @dev Deprecates a registered implementation * @param implementation Address of the implementation to be deprecated */ function deprecate(address implementation) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-registry/contracts/implementations/IImplementation.sol'; /** * @title IStrategy * @dev Strategy interface required by Mimic Smart Vaults. It must follow the IImplementation interface. */ interface IStrategy is IImplementation { /** * @dev Tokens accepted to join the strategy */ function joinTokens() external view returns (address[] memory); /** * @dev Tokens accepted to exit the strategy */ function exitTokens() external view returns (address[] memory); /** * @dev Tells how much a value unit means expressed in the asset token. * For example, if a strategy has a value of 100 in T0, and then it has a value of 120 in T1, * and the value rate is 1.5, it means the strategy has earned 30 strategy tokens between T0 and T1. */ function valueRate() external view returns (uint256); /** * @dev Tells the last value an account has over time. Note this value can be outdated: there could be rewards to * be claimed that will affect the accrued value. For example, if an account has a value of 100 in T0, and then it * has a value of 120 in T1, it means it gained a 20% between T0 and T1. * @param account Address of the account querying the last value of */ function lastValue(address account) external view returns (uint256); /** * @dev Claim any existing rewards * @param data Arbitrary extra data * @return tokens Addresses of the tokens received as rewards * @return amounts Amounts of the tokens received as rewards */ function claim(bytes memory data) external returns (address[] memory tokens, uint256[] memory amounts); /** * @dev Join the interfaced DeFi protocol * @param tokensIn List of token addresses to join with * @param amountsIn List of token amounts to join with * @param slippage Slippage value to join with * @param data Arbitrary extra data * @return tokensOut List of token addresses received after the join * @return amountsOut List of token amounts received after the join * @return value Value represented by the joined amount */ function join(address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data) external returns (address[] memory tokensOut, uint256[] memory amountsOut, uint256 value); /** * @dev Exit the interfaced DeFi protocol * @param tokensIn List of token addresses to exit with * @param amountsIn List of token amounts to exit with * @param slippage Slippage value to exit with * @param data Arbitrary extra data * @return tokensOut List of token addresses received after the exit * @return amountsOut List of token amounts received after the exit * @return value Value represented by the exited amount */ function exit(address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data) external returns (address[] memory tokensOut, uint256[] memory amountsOut, uint256 value); }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-registry/contracts/implementations/IImplementation.sol'; /** * @title ISwapConnector * @dev Swap Connector interface to perform token swaps. It must follow the IImplementation interface. */ interface ISwapConnector is IImplementation { /** * @dev Enum identifying the sources proposed: Uniswap V2, Uniswap V3, Balancer V2, Paraswap V5, 1inch V5, and Hop. */ enum Source { UniswapV2, UniswapV3, BalancerV2, ParaswapV5, OneInchV5, Hop } /** * @dev Swaps two tokens * @param source Source to execute the requested swap * @param tokenIn Token being sent * @param tokenOut Token being received * @param amountIn Amount of tokenIn being swapped * @param minAmountOut Minimum amount of tokenOut willing to receive * @param data Encoded data to specify different swap parameters depending on the source picked */ function swap( uint8 source, address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, bytes memory data ) external returns (uint256 amountOut); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/Address.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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; } _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; _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; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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) (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 functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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. It 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)`. // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`. // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`. // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a // good first aproximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1; uint256 x = a; if (x >> 128 > 0) { x >>= 128; result <<= 64; } if (x >> 64 > 0) { x >>= 64; result <<= 32; } if (x >> 32 > 0) { x >>= 32; result <<= 16; } if (x >> 16 > 0) { x >>= 16; result <<= 8; } if (x >> 8 > 0) { x >>= 8; result <<= 4; } if (x >> 4 > 0) { x >>= 4; result <<= 2; } if (x >> 2 > 0) { result <<= 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) { uint256 result = sqrt(a); if (rounding == Rounding.Up && result * result < a) { result += 1; } return result; } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/utils/Address.sol'; import '@mimic-fi/v2-bridge-connector/contracts/IBridgeConnector.sol'; /** * @title BridgeConnectorLib * @dev Library used to delegate-call bridge ops and decode return data correctly */ library BridgeConnectorLib { /** * @dev Delegate-calls a bridge to the bridge connector and decodes de expected data * IMPORTANT! This helper method does not check any of the given params, these should be checked beforehand. */ function bridge( address connector, uint8 source, uint256 chainId, address token, uint256 amountIn, uint256 minAmountOut, address recipient, bytes memory data ) internal { bytes memory bridgeData = abi.encodeWithSelector( IBridgeConnector.bridge.selector, source, chainId, token, amountIn, minAmountOut, recipient, data ); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = connector.delegatecall(bridgeData); Address.verifyCallResult(success, returndata, 'BRIDGE_CALL_REVERTED'); } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/utils/Address.sol'; import '@mimic-fi/v2-strategies/contracts/IStrategy.sol'; /** * @title StrategyLib * @dev Library used to delegate-call to strategy and decode return data correctly */ library StrategyLib { /** * @dev Delegate-calls a claim to a strategy and decodes de expected data * IMPORTANT! This helper method does not check any of the given params, these should be checked beforehand. */ function claim(address strategy, bytes memory data) internal returns (address[] memory, uint256[] memory) { bytes memory claimData = abi.encodeWithSelector(IStrategy.claim.selector, data); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = strategy.delegatecall(claimData); Address.verifyCallResult(success, returndata, 'CLAIM_CALL_REVERTED'); return abi.decode(returndata, (address[], uint256[])); } /** * @dev Delegate-calls a join to a strategy and decodes de expected data * IMPORTANT! This helper method does not check any of the given params, these should be checked beforehand. */ function join( address strategy, address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data ) internal returns (address[] memory tokensOut, uint256[] memory amountsOut, uint256 value) { bytes memory joinData = abi.encodeWithSelector(IStrategy.join.selector, tokensIn, amountsIn, slippage, data); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = strategy.delegatecall(joinData); Address.verifyCallResult(success, returndata, 'JOIN_CALL_REVERTED'); return abi.decode(returndata, (address[], uint256[], uint256)); } /** * @dev Delegate-calls a exit to a strategy and decodes de expected data * IMPORTANT! This helper method does not check any of the given params, these should be checked beforehand. */ function exit( address strategy, address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data ) internal returns (address[] memory tokensOut, uint256[] memory amountsOut, uint256 value) { bytes memory exitData = abi.encodeWithSelector(IStrategy.exit.selector, tokensIn, amountsIn, slippage, data); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = strategy.delegatecall(exitData); Address.verifyCallResult(success, returndata, 'EXIT_CALL_REVERTED'); return abi.decode(returndata, (address[], uint256[], uint256)); } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/utils/Address.sol'; import '@mimic-fi/v2-swap-connector/contracts/ISwapConnector.sol'; /** * @title SwapConnectorLib * @dev Library used to delegate-call swaps and decode return data correctly */ library SwapConnectorLib { /** * @dev Delegate-calls a swap to the swap connector and decodes de expected data * IMPORTANT! This helper method does not check any of the given params, these should be checked beforehand. */ function swap( address connector, uint8 source, address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, bytes memory data ) internal returns (uint256 amountOut) { bytes memory swapData = abi.encodeWithSelector( ISwapConnector.swap.selector, source, tokenIn, tokenOut, amountIn, minAmountOut, data ); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = connector.delegatecall(swapData); Address.verifyCallResult(success, returndata, 'SWAP_CALL_REVERTED'); return abi.decode(returndata, (uint256)); } }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-helpers/contracts/auth/IAuthorizer.sol'; import '@mimic-fi/v2-price-oracle/contracts/feeds/IPriceFeedProvider.sol'; import '@mimic-fi/v2-registry/contracts/implementations/IImplementation.sol'; /** * @title ISmartVault * @dev Mimic Smart Vault interface to manage assets. It must support also `IImplementation` and `IAuthorizer` */ interface ISmartVault is IPriceFeedProvider, IImplementation, IAuthorizer { enum SwapLimit { Slippage, MinAmountOut } enum BridgeLimit { Slippage, MinAmountOut } /** * @dev Emitted every time a new strategy is set for the Smart Vault */ event StrategySet(address indexed strategy, bool allowed); /** * @dev Emitted every time a new price oracle is set for the Smart Vault */ event PriceOracleSet(address indexed priceOracle); /** * @dev Emitted every time a new swap connector is set for the Smart Vault */ event SwapConnectorSet(address indexed swapConnector); /** * @dev Emitted every time a new bridge connector is set for the Smart Vault */ event BridgeConnectorSet(address indexed bridgeConnector); /** * @dev Emitted every time a new fee collector is set */ event FeeCollectorSet(address indexed feeCollector); /** * @dev Emitted every time the withdraw fee percentage is set */ event WithdrawFeeSet(uint256 pct, uint256 cap, address token, uint256 period); /** * @dev Emitted every time the performance fee percentage is set */ event PerformanceFeeSet(uint256 pct, uint256 cap, address token, uint256 period); /** * @dev Emitted every time the swap fee percentage is set */ event SwapFeeSet(uint256 pct, uint256 cap, address token, uint256 period); /** * @dev Emitted every time the bridge fee percentage is set */ event BridgeFeeSet(uint256 pct, uint256 cap, address token, uint256 period); /** * @dev Emitted every time `call` is called */ event Call(address indexed target, bytes callData, uint256 value, bytes result, bytes data); /** * @dev Emitted every time `collect` is called */ event Collect(address indexed token, address indexed from, uint256 collected, bytes data); /** * @dev Emitted every time `withdraw` is called */ event Withdraw(address indexed token, address indexed recipient, uint256 withdrawn, uint256 fee, bytes data); /** * @dev Emitted every time `wrap` is called */ event Wrap(uint256 amount, uint256 wrapped, bytes data); /** * @dev Emitted every time `unwrap` is called */ event Unwrap(uint256 amount, uint256 unwrapped, bytes data); /** * @dev Emitted every time `claim` is called */ event Claim(address indexed strategy, address[] tokens, uint256[] amounts, bytes data); /** * @dev Emitted every time `join` is called */ event Join( address indexed strategy, address[] tokensIn, uint256[] amountsIn, address[] tokensOut, uint256[] amountsOut, uint256 value, uint256 slippage, bytes data ); /** * @dev Emitted every time `exit` is called */ event Exit( address indexed strategy, address[] tokensIn, uint256[] amountsIn, address[] tokensOut, uint256[] amountsOut, uint256 value, uint256[] fees, uint256 slippage, bytes data ); /** * @dev Emitted every time `swap` is called */ event Swap( uint8 indexed source, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut, uint256 minAmountOut, uint256 fee, bytes data ); /** * @dev Emitted every time `bridge` is called */ event Bridge( uint8 indexed source, uint256 indexed chainId, address indexed token, uint256 amountIn, uint256 minAmountOut, uint256 fee, address recipient, bytes data ); /** * @dev Tells a strategy is allowed or not * @param strategy Address of the strategy being queried */ function isStrategyAllowed(address strategy) external view returns (bool); /** * @dev Tells the invested value for a strategy * @param strategy Address of the strategy querying the invested value of */ function investedValue(address strategy) external view returns (uint256); /** * @dev Tells the last value accrued for a strategy. Note this value can be outdated. * @param strategy Address of the strategy querying the last value of */ function lastValue(address strategy) external view returns (uint256); /** * @dev Tells the price oracle associated to a Smart Vault */ function priceOracle() external view returns (address); /** * @dev Tells the swap connector associated to a Smart Vault */ function swapConnector() external view returns (address); /** * @dev Tells the bridge connector associated to a Smart Vault */ function bridgeConnector() external view returns (address); /** * @dev Tells the address where fees will be deposited */ function feeCollector() external view returns (address); /** * @dev Tells the withdraw fee configuration */ function withdrawFee() external view returns (uint256 pct, uint256 cap, address token, uint256 period, uint256 totalCharged, uint256 nextResetTime); /** * @dev Tells the performance fee configuration */ function performanceFee() external view returns (uint256 pct, uint256 cap, address token, uint256 period, uint256 totalCharged, uint256 nextResetTime); /** * @dev Tells the swap fee configuration */ function swapFee() external view returns (uint256 pct, uint256 cap, address token, uint256 period, uint256 totalCharged, uint256 nextResetTime); /** * @dev Tells the bridge fee configuration */ function bridgeFee() external view returns (uint256 pct, uint256 cap, address token, uint256 period, uint256 totalCharged, uint256 nextResetTime); /** * @dev Tells the address of the wrapped native token */ function wrappedNativeToken() external view returns (address); /** * @dev Sets a new strategy as allowed or not for a Smart Vault * @param strategy Address of the strategy to be set * @param allowed Whether the strategy is allowed or not */ function setStrategy(address strategy, bool allowed) external; /** * @dev Sets a new price oracle to a Smart Vault * @param newPriceOracle Address of the new price oracle to be set */ function setPriceOracle(address newPriceOracle) external; /** * @dev Sets a new swap connector to a Smart Vault * @param newSwapConnector Address of the new swap connector to be set */ function setSwapConnector(address newSwapConnector) external; /** * @dev Sets a new bridge connector to a Smart Vault * @param newBridgeConnector Address of the new bridge connector to be set */ function setBridgeConnector(address newBridgeConnector) external; /** * @dev Sets a new fee collector * @param newFeeCollector Address of the new fee collector to be set */ function setFeeCollector(address newFeeCollector) external; /** * @dev Sets a new withdraw fee configuration * @param pct Withdraw fee percentage to be set * @param cap New maximum amount of withdraw fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the withdraw fee */ function setWithdrawFee(uint256 pct, uint256 cap, address token, uint256 period) external; /** * @dev Sets a new performance fee configuration * @param pct Performance fee percentage to be set * @param cap New maximum amount of performance fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the performance fee */ function setPerformanceFee(uint256 pct, uint256 cap, address token, uint256 period) external; /** * @dev Sets a new swap fee configuration * @param pct Swap fee percentage to be set * @param cap New maximum amount of swap fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the swap fee */ function setSwapFee(uint256 pct, uint256 cap, address token, uint256 period) external; /** * @dev Sets a new bridge fee configuration * @param pct Bridge fee percentage to be set * @param cap New maximum amount of bridge fees to be charged per period * @param token Address of the token cap to be set * @param period New cap period length in seconds for the bridge fee */ function setBridgeFee(uint256 pct, uint256 cap, address token, uint256 period) external; /** * @dev Tells the price of a token (base) in a given quote * @param base Token to rate * @param quote Token used for the price rate */ function getPrice(address base, address quote) external view returns (uint256); /** * @dev Execute an arbitrary call from a Smart Vault * @param target Address where the call will be sent * @param callData Calldata to be used for the call * @param value Value in wei that will be attached to the call * @param data Extra data that may enable or not different behaviors depending on the implementation * @return result Call response if it was successful, otherwise it reverts */ function call(address target, bytes memory callData, uint256 value, bytes memory data) external returns (bytes memory result); /** * @dev Collect tokens from a sender to a Smart Vault * @param token Address of the token to be collected * @param from Address where the tokens will be transfer from * @param amount Amount of tokens to be transferred * @param data Extra data that may enable or not different behaviors depending on the implementation * @return collected Amount of tokens assigned to the Smart Vault */ function collect(address token, address from, uint256 amount, bytes memory data) external returns (uint256 collected); /** * @dev Withdraw tokens to an external account * @param token Address of the token to be withdrawn * @param amount Amount of tokens to withdraw * @param recipient Address where the tokens will be transferred to * @param data Extra data that may enable or not different behaviors depending on the implementation * @return withdrawn Amount of tokens transferred to the recipient address */ function withdraw(address token, uint256 amount, address recipient, bytes memory data) external returns (uint256 withdrawn); /** * @dev Wrap an amount of native tokens to the wrapped ERC20 version of it * @param amount Amount of native tokens to be wrapped * @param data Extra data that may enable or not different behaviors depending on the implementation * @return wrapped Amount of tokens wrapped */ function wrap(uint256 amount, bytes memory data) external returns (uint256 wrapped); /** * @dev Unwrap an amount of wrapped native tokens * @param amount Amount of wrapped native tokens to unwrapped * @param data Extra data that may enable or not different behaviors depending on the implementation * @return unwrapped Amount of tokens unwrapped */ function unwrap(uint256 amount, bytes memory data) external returns (uint256 unwrapped); /** * @dev Claim strategy rewards * @param strategy Address of the strategy to claim rewards * @param data Extra data that may enable or not different behaviors depending on the implementation * @return tokens Addresses of the tokens received as rewards * @return amounts Amounts of the tokens received as rewards */ function claim(address strategy, bytes memory data) external returns (address[] memory tokens, uint256[] memory amounts); /** * @dev Join a strategy with an amount of tokens * @param strategy Address of the strategy to join * @param tokensIn List of token addresses to join with * @param amountsIn List of token amounts to join with * @param slippage Slippage that will be used to compute the join * @param data Extra data that may enable or not different behaviors depending on the implementation * @return tokensOut List of token addresses received after the join * @return amountsOut List of token amounts received after the join */ function join( address strategy, address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data ) external returns (address[] memory tokensOut, uint256[] memory amountsOut); /** * @dev Exit a strategy * @param strategy Address of the strategy to exit * @param tokensIn List of token addresses to exit with * @param amountsIn List of token amounts to exit with * @param slippage Slippage that will be used to compute the exit * @param data Extra data that may enable or not different behaviors depending on the implementation * @return tokensOut List of token addresses received after the exit * @return amountsOut List of token amounts received after the exit */ function exit( address strategy, address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data ) external returns (address[] memory tokensOut, uint256[] memory amountsOut); /** * @dev Swaps two tokens * @param source Source to request the swap. It depends on the Swap Connector attached to a Smart Vault. * @param tokenIn Token being sent * @param tokenOut Token being received * @param amountIn Amount of tokenIn being swapped * @param limitType Swap limit to be applied: slippage or min amount out * @param limitAmount Amount of the swap limit to be applied depending on limitType * @param data Extra data that may enable or not different behaviors depending on the implementation * @return amountOut Received amount of tokens out */ function swap( uint8 source, address tokenIn, address tokenOut, uint256 amountIn, SwapLimit limitType, uint256 limitAmount, bytes memory data ) external returns (uint256 amountOut); /** * @dev Bridge assets to another chain * @param source Source to request the bridge. It depends on the Bridge Connector attached to a Smart Vault. * @param chainId ID of the destination chain * @param token Address of the token to be bridged * @param amount Amount of tokens to be bridged * @param limitType Swap limit to be applied: slippage or min amount out * @param limitAmount Amount of the swap limit to be applied depending on limitType * @param recipient Address that will receive the tokens on the destination chain * @param data Extra data that may enable or not different behaviors depending on the implementation * @return bridged Amount requested to be bridged after fees */ function bridge( uint8 source, uint256 chainId, address token, uint256 amount, BridgeLimit limitType, uint256 limitAmount, address recipient, bytes memory data ) external returns (uint256 bridged); }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@mimic-fi/v2-registry/contracts/implementations/IImplementation.sol'; /** * @title ISmartVaultsFactory * @dev Smart Vaults Factory interface, it must follow the IImplementation interface. */ interface ISmartVaultsFactory is IImplementation { /** * @dev Emitted every time a new Smart Vault instance is created */ event Created(address indexed implementation, address indexed instance, bytes initializeResult); /** * @dev Tells the implementation associated to a contract instance * @param instance Address of the instance to request it's implementation */ function implementationOf(address instance) external view returns (address); /** * @dev Creates a new Smart Vault pointing to a registered implementation * @param salt Salt bytes to derivate the address of the new instance * @param implementation Address of the implementation to be instanced * @param initializeData Arbitrary data to be sent after deployment * @return instance Address of the new instance created */ function create(bytes32 salt, address implementation, bytes memory initializeData) external returns (address); }
// SPDX-License-Identifier: GPL-3.0-or-later // 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; import '@openzeppelin/contracts/proxy/Clones.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@mimic-fi/v2-helpers/contracts/auth/Authorizer.sol'; import '@mimic-fi/v2-registry/contracts/registry/IRegistry.sol'; import '@mimic-fi/v2-registry/contracts/implementations/BaseImplementation.sol'; import './ISmartVaultsFactory.sol'; /** * @title SmartVaultsFactory * @dev */ contract SmartVaultsFactory is ISmartVaultsFactory, BaseImplementation { using Address for address; // Smart Vaults Factory namespace bytes32 public constant override NAMESPACE = keccak256('SMART_VAULTS_FACTORY'); // Namespace to use by this deployer to fetch ISmartVault implementations from the Mimic Registry bytes32 private constant SMART_VAULT_NAMESPACE = keccak256('SMART_VAULT'); // List of instances' implementations indexed by instance address mapping (address => address) public override implementationOf; /** * @dev Creates a new Smart Vaults Factory implementation * @param registry Address of the Mimic Registry to be referenced */ constructor(address registry) BaseImplementation(registry) { // solhint-disable-previous-line no-empty-blocks } /** * @dev Creates a new Smart Vault pointing to a registered implementation using CREATE2 * @param salt Salt bytes to derivate the address of the new instance * @param implementation Address of the implementation to be instanced. It must be registered and not deprecated. * @param initializeData Arbitrary data to be sent after deployment. It can be used to initialize the new instance. * @return instance Address of the new instance created */ function create(bytes32 salt, address implementation, bytes memory initializeData) external override returns (address instance) { require(implementation != address(0), 'IMPLEMENTATION_ADDRESS_ZERO'); require(IImplementation(implementation).NAMESPACE() == SMART_VAULT_NAMESPACE, 'BAD_IMPLEMENTATION_NAMESPACE'); require(IRegistry(registry).isActive(SMART_VAULT_NAMESPACE, implementation), 'BAD_SMART_VAULT_IMPLEMENTATION'); bytes32 senderSalt = keccak256(abi.encodePacked(msg.sender, salt)); instance = Clones.cloneDeterministic(address(implementation), senderSalt); implementationOf[instance] = implementation; bytes memory result = initializeData.length == 0 ? new bytes(0) : instance.functionCall(initializeData, 'SMART_VAULT_INIT_FAILED'); emit Created(implementation, instance, result); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@mimic-fi/v2-bridge-connector/contracts/IBridgeConnector.sol'; import '@mimic-fi/v2-registry/contracts/implementations/BaseImplementation.sol'; import '../samples/BridgeMock.sol'; contract BridgeConnectorMock is IBridgeConnector, BaseImplementation { bytes32 public constant override NAMESPACE = keccak256('BRIDGE_CONNECTOR'); BridgeMock public immutable bridgeMock; constructor(address registry) BaseImplementation(registry) { bridgeMock = new BridgeMock(); } function bridge( uint8, /* source */ uint256, /* chainId */ address token, uint256 amountIn, uint256 minAmountOut, address recipient, bytes memory data ) external override { IERC20(token).approve(address(bridgeMock), amountIn); return bridgeMock.bridge(token, amountIn, minAmountOut, recipient, data); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@mimic-fi/v2-helpers/contracts/math/FixedPoint.sol'; import '@mimic-fi/v2-price-oracle/contracts/oracle/IPriceOracle.sol'; import '@mimic-fi/v2-registry/contracts/implementations/BaseImplementation.sol'; contract PriceOracleMock is IPriceOracle, BaseImplementation { bytes32 public constant override NAMESPACE = keccak256('PRICE_ORACLE'); struct Feed { bool set; uint256 rate; } mapping (address => mapping (address => Feed)) public mockedFeeds; constructor(address registry) BaseImplementation(registry) { // solhint-disable-previous-line no-empty-blocks } function mockRate(address base, address quote, uint256 newMockedRate) external { Feed storage feed = mockedFeeds[base][quote]; feed.set = true; feed.rate = newMockedRate; } function getPrice(address, address base, address quote) external view override returns (uint256) { if (base == quote) return FixedPoint.ONE; Feed storage feed = mockedFeeds[base][quote]; require(feed.set, 'PRICE_ORACLE_FEED_NOT_SET'); return feed.rate; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@mimic-fi/v2-helpers/contracts/math/FixedPoint.sol'; import '@mimic-fi/v2-strategies/contracts/IStrategy.sol'; import '@mimic-fi/v2-registry/contracts/implementations/BaseImplementation.sol'; import '../samples/TokenMock.sol'; contract StrategyMock is IStrategy, BaseImplementation { using FixedPoint for uint256; bytes32 public constant override NAMESPACE = keccak256('STRATEGY'); address public immutable lpt; address public immutable token; address public immutable rewardToken; event Claimed(bytes data); event Joined(address[] tokensIn, uint256[] amountsIn, uint256 slippage, bytes data); event Exited(address[] tokensIn, uint256[] amountsIn, uint256 slippage, bytes data); constructor(address registry) BaseImplementation(registry) { lpt = address(new TokenMock('LPT')); token = address(new TokenMock('TKN')); rewardToken = address(new TokenMock('REW')); } function mockGains(address account, uint256 multiplier) external { uint256 balance = IERC20(lpt).balanceOf(account); TokenMock(lpt).mint(account, balance * (multiplier - 1)); } function mockLosses(address account, uint256 divisor) external { uint256 balance = IERC20(lpt).balanceOf(account); TokenMock(lpt).burn(account, balance / divisor); } function joinTokens() public view override returns (address[] memory tokens) { tokens = new address[](1); tokens[0] = token; } function exitTokens() public view override returns (address[] memory tokens) { tokens = new address[](1); tokens[0] = lpt; } function valueRate() public pure override returns (uint256) { return FixedPoint.ONE; } function lastValue(address account) public view override returns (uint256) { return IERC20(lpt).balanceOf(account); } function claim(bytes memory data) external override returns (address[] memory tokens, uint256[] memory amounts) { uint256 amount = abi.decode(data, (uint256)); TokenMock(rewardToken).mint(address(this), amount); tokens = new address[](1); tokens[0] = rewardToken; amounts = new uint256[](1); amounts[0] = amount; emit Claimed(data); } function join(address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data) external override returns (address[] memory tokensOut, uint256[] memory amountsOut, uint256 value) { require(tokensIn.length == 1, 'STRATEGY_INVALID_TOKENS_IN_LEN'); require(amountsIn.length == 1, 'STRATEGY_INVALID_AMOUNTS_IN_LEN'); require(tokensIn[0] == token, 'STRATEGY_INVALID_JOIN_TOKEN'); tokensOut = exitTokens(); amountsOut = new uint256[](1); amountsOut[0] = amountsIn[0]; TokenMock(token).burn(address(this), amountsIn[0]); TokenMock(lpt).mint(address(this), amountsOut[0]); value = amountsOut[0].mulDown(valueRate()); emit Joined(tokensIn, amountsIn, slippage, data); } function exit(address[] memory tokensIn, uint256[] memory amountsIn, uint256 slippage, bytes memory data) external override returns (address[] memory tokensOut, uint256[] memory amountsOut, uint256 value) { require(tokensIn.length == 1, 'STRATEGY_INVALID_TOKENS_IN_LEN'); require(amountsIn.length == 1, 'STRATEGY_INVALID_AMOUNTS_IN_LEN'); require(tokensIn[0] == lpt, 'STRATEGY_INVALID_EXIT_TOKEN'); tokensOut = joinTokens(); amountsOut = new uint256[](1); amountsOut[0] = amountsIn[0]; TokenMock(lpt).burn(address(this), amountsIn[0]); TokenMock(token).mint(address(this), amountsOut[0]); value = amountsIn[0].divUp(valueRate()); emit Exited(tokensIn, amountsIn, slippage, data); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@mimic-fi/v2-swap-connector/contracts/ISwapConnector.sol'; import '@mimic-fi/v2-registry/contracts/implementations/BaseImplementation.sol'; import '../samples/DexMock.sol'; contract SwapConnectorMock is ISwapConnector, BaseImplementation { bytes32 public constant override NAMESPACE = keccak256('SWAP_CONNECTOR'); DexMock public immutable dex; constructor(address registry) BaseImplementation(registry) { dex = new DexMock(); } function mockRate(uint256 newRate) external { dex.mockRate(newRate); } function swap( uint8, /* source */ address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, bytes memory data ) external override returns (uint256 amountOut) { IERC20(tokenIn).approve(address(dex), amountIn); return dex.swap(tokenIn, tokenOut, amountIn, minAmountOut, data); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; contract BridgeMock { function bridge(address token, uint256 amount, uint256, address, bytes memory) external { IERC20(token).transferFrom(msg.sender, address(this), amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@mimic-fi/v2-helpers/contracts/math/FixedPoint.sol'; contract DexMock { using FixedPoint for uint256; uint256 public mockedRate; constructor() { mockedRate = FixedPoint.ONE; } function mockRate(uint256 newRate) external { mockedRate = newRate; } function swap(address tokenIn, address tokenOut, uint256 amountIn, uint256, bytes memory) external returns (uint256 amountOut) { IERC20(tokenIn).transferFrom(msg.sender, address(this), amountIn); amountOut = amountIn.mulDown(mockedRate); IERC20(tokenOut).transfer(msg.sender, amountOut); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; contract TokenMock is ERC20 { constructor(string memory symbol) ERC20(symbol, symbol) { // solhint-disable-previous-line no-empty-blocks } function mint(address account, uint256 amount) external { _mint(account, amount); } function burn(address account, uint256 amount) external { _burn(account, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@mimic-fi/v2-helpers/contracts/utils/IWrappedNativeToken.sol'; contract WrappedNativeTokenMock is IWrappedNativeToken { uint8 public decimals = 18; string public name = 'Wrapped Native Token'; string public symbol = 'WNT'; event Deposit(address indexed to, uint256 amount); event Withdrawal(address indexed from, uint256 amount); mapping (address => uint256) public override balanceOf; mapping (address => mapping (address => uint256)) public override allowance; receive() external payable { deposit(); } function deposit() public payable override { balanceOf[msg.sender] += msg.value; emit Deposit(msg.sender, msg.value); } function withdraw(uint256 amount) public override { require(balanceOf[msg.sender] >= amount, 'WNT_NOT_ENOUGH_BALANCE'); balanceOf[msg.sender] -= amount; payable(msg.sender).transfer(amount); emit Withdrawal(msg.sender, amount); } function totalSupply() public view override returns (uint256) { return address(this).balance; } function approve(address spender, uint256 amount) public override returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public override returns (bool) { return transferFrom(msg.sender, to, amount); } function transferFrom(address from, address to, uint256 amount) public override returns (bool) { require(balanceOf[from] >= amount, 'NOT_ENOUGH_BALANCE'); if (from != msg.sender && allowance[from][msg.sender] != type(uint256).max) { require(allowance[from][msg.sender] >= amount, 'NOT_ENOUGH_ALLOWANCE'); allowance[from][msg.sender] -= amount; } balanceOf[from] -= amount; balanceOf[to] += amount; emit Transfer(from, to, amount); return true; } }
{ "optimizer": { "enabled": true, "runs": 10000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract ABI
[{"inputs":[{"internalType":"address","name":"_wrappedNativeToken","type":"address"},{"internalType":"address","name":"_registry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":false,"internalType":"bytes4","name":"what","type":"bytes4"}],"name":"Authorized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint8","name":"source","type":"uint8"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Bridge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bridgeConnector","type":"address"}],"name":"BridgeConnectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"pct","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cap","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"BridgeFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes","name":"callData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"result","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Call","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"collected","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Collect","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokensIn","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"indexed":false,"internalType":"address[]","name":"tokensOut","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"fees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"slippage","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Exit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"feeCollector","type":"address"}],"name":"FeeCollectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokensIn","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"indexed":false,"internalType":"address[]","name":"tokensOut","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"slippage","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Join","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"pct","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cap","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"PerformanceFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"base","type":"address"},{"indexed":true,"internalType":"address","name":"quote","type":"address"},{"indexed":false,"internalType":"address","name":"feed","type":"address"}],"name":"PriceFeedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"priceOracle","type":"address"}],"name":"PriceOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"},{"indexed":false,"internalType":"bool","name":"allowed","type":"bool"}],"name":"StrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint8","name":"source","type":"uint8"},{"indexed":true,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"swapConnector","type":"address"}],"name":"SwapConnectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"pct","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cap","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"SwapFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":false,"internalType":"bytes4","name":"what","type":"bytes4"}],"name":"Unauthorized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unwrapped","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Unwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"withdrawn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"pct","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cap","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"WithdrawFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"wrapped","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Wrap","type":"event"},{"inputs":[],"name":"ANY_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAMESPACE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"},{"internalType":"bytes4","name":"what","type":"bytes4"}],"name":"authorize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"source","type":"uint8"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum ISmartVault.BridgeLimit","name":"limitType","type":"uint8"},{"internalType":"uint256","name":"limitAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"bridge","outputs":[{"internalType":"uint256","name":"bridged","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bridgeConnector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeFee","outputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"totalCharged","type":"uint256"},{"internalType":"uint256","name":"nextResetTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"call","outputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"strategy","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"collect","outputs":[{"internalType":"uint256","name":"collected","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"strategy","type":"address"},{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"exit","outputs":[{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"getPriceFeed","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"investedValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"},{"internalType":"bytes4","name":"what","type":"bytes4"}],"name":"isAuthorized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isStrategyAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"strategy","type":"address"},{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"join","outputs":[{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"strategy","type":"address"}],"name":"lastValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"performanceFee","outputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"totalCharged","type":"uint256"},{"internalType":"uint256","name":"nextResetTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newBridgeConnector","type":"address"}],"name":"setBridgeConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"setBridgeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newFeeCollector","type":"address"}],"name":"setFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"setPerformanceFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"address","name":"feed","type":"address"}],"name":"setPriceFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"bases","type":"address[]"},{"internalType":"address[]","name":"quotes","type":"address[]"},{"internalType":"address[]","name":"feeds","type":"address[]"}],"name":"setPriceFeeds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPriceOracle","type":"address"}],"name":"setPriceOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"strategy","type":"address"},{"internalType":"bool","name":"allowed","type":"bool"}],"name":"setStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newSwapConnector","type":"address"}],"name":"setSwapConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"setSwapFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"setWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"source","type":"uint8"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"enum ISmartVault.SwapLimit","name":"limitType","type":"uint8"},{"internalType":"uint256","name":"limitAmount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapConnector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapFee","outputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"totalCharged","type":"uint256"},{"internalType":"uint256","name":"nextResetTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"},{"internalType":"bytes4","name":"what","type":"bytes4"}],"name":"unauthorize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"unwrap","outputs":[{"internalType":"uint256","name":"unwrapped","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"withdrawn","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawFee","outputs":[{"internalType":"uint256","name":"pct","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"totalCharged","type":"uint256"},{"internalType":"uint256","name":"nextResetTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"wrap","outputs":[{"internalType":"uint256","name":"wrapped","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Loading...LoadingLoading...Loading
Loading...Loading
Loading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingMultichain Portfolio | 30 Chains
Chain Token Portfolio % Price Amount Value POL 57.66% $0.015315 4,643,429.7513 $71,115.71 POL 0.82% $1 1,009.2687 $1,011.29 POL 0.46% $0.697481 816.7144 $569.64 POL 0.16% $0.693458 285.2817 $197.83 POL 0.15% $1 183.4432 $183.81 POL 0.13% $1 158.1601 $158.48 POL 0.09% $1.38 84.7936 $117.02 POL 0.09% $3,864.66 0.0298 $115 POL 0.08% $258.75 0.3813 $98.66 POL 0.08% $0.006569 14,914.01 $97.97 POL 0.07% $23.91 3.7725 $90.2 POL 0.07% $386.91 0.219 $84.72 POL 0.06% $0.066827 1,163.8607 $77.78 POL 0.06% $2.16 35.9602 $77.67 POL 0.06% $0.025257 2,973.1824 $75.09 POL 0.06% $97,385 0.00074785 $72.83 POL 0.05% <$0.000001 3,659,703,030.7027 $64.41 POL 0.05% $0.228064 272.6269 $62.18 POL 0.05% $0.064484 909.4378 $58.64 POL 0.05% $11.42 4.974 $56.8 POL 0.04% $1.11 45.1892 $50.16 POL 0.03% $0.266382 150.0599 $39.97 POL 0.03% $0.063042 631.6977 $39.82 POL 0.03% $0.00168 20,868.2813 $35.05 POL 0.03% $0.003812 8,909.9454 $33.96 POL 0.03% $1 32.6649 $32.7 POL 0.03% $0.023633 1,375.7623 $32.51 POL 0.03% $0.000004 7,875,136.6767 $32.37 POL 0.02% $0.122774 246.6831 $30.29 POL 0.02% $0.000229 129,836.6266 $29.78 POL 0.02% $0.002533 11,621.4964 $29.43 POL 0.02% $0.013666 2,142.639 $29.28 POL 0.02% $0.000044 625,695.4582 $27.48 POL 0.02% $0.135315 163.9447 $22.18 POL 0.02% $0.002944 6,762.1972 $19.91 POL 0.02% $0.233156 83.7264 $19.52 POL 0.01% $0.019939 896.9575 $17.88 POL 0.01% $0.023352 753.9177 $17.61 POL 0.01% $3.97 4.409 $17.5 POL 0.01% $0.007761 2,166.9527 $16.82 POL 0.01% $0.000031 541,999.1293 $16.81 POL 0.01% $0.001397 11,281.5912 $15.75 POL 0.01% $4,562.3 0.00318119 $14.51 POL 0.01% $0.004814 2,910.1046 $14.01 POL 0.01% $0.001206 11,361.0144 $13.7 POL 0.01% $3.11 4.3959 $13.67 POL 0.01% $0.849209 15.7277 $13.36 POL 0.01% $3.72 3.5427 $13.18 POL 0.01% <$0.000001 58,485,761.6391 $13.14 POL 0.01% $10.33 1.2475 $12.89 POL 0.01% $0.457786 27.0699 $12.39 POL <0.01% $0.038987 312.8646 $12.2 POL <0.01% $0.000362 33,393.0998 $12.08 POL <0.01% $0.756606 15.7866 $11.94 POL <0.01% $0.020858 556.8421 $11.61 POL <0.01% $0.370432 28.9953 $10.74 POL <0.01% $0.90994 11.7195 $10.66 POL <0.01% $0.087343 117.9862 $10.31 POL <0.01% $0.001949 5,098.0809 $9.94 POL <0.01% $3,862.76 0.0025026 $9.67 POL <0.01% $0.002879 3,330.5708 $9.59 POL <0.01% $0.107911 88.2212 $9.52 POL <0.01% $1.78 4.8325 $8.6 POL <0.01% $0.103846 81.2044 $8.43 POL <0.01% $1.08 7.79 $8.41 POL <0.01% $0.029692 280.5626 $8.33 POL <0.01% $0.000011 756,002.3592 $8.13 POL <0.01% $0.171082 41.9267 $7.17 POL <0.01% $117.71 0.0583 $6.87 POL <0.01% $1 6.751 $6.75 POL <0.01% $0.000972 6,877.9078 $6.68 POL <0.01% $0.065291 100.575 $6.57 POL <0.01% $0.268839 23.2351 $6.25 POL <0.01% $0.034556 176.861 $6.11 POL <0.01% <$0.000001 20,167,045.9115 $6.03 POL <0.01% $0.000028 211,266.4726 $5.98 POL <0.01% $0.999942 5.98 $5.98 POL <0.01% $0.015723 378.0525 $5.94 POL <0.01% $0.005231 1,118.8146 $5.85 POL <0.01% $51.69 0.1114 $5.76 POL <0.01% $2.84 1.9734 $5.6 POL <0.01% $0.001198 4,522.3112 $5.42 POL <0.01% $0.000001 5,134,689.9884 $5.39 POL <0.01% $0.007024 751.3612 $5.28 POL <0.01% $0.038093 137.7815 $5.25 POL <0.01% $0.999841 5.1853 $5.18 POL <0.01% $0.014143 365.3352 $5.17 POL <0.01% $0.002503 1,984.8418 $4.97 POL <0.01% $0.003946 1,247.9716 $4.92 POL <0.01% $0.831807 5.9093 $4.92 POL <0.01% $0.836486 5.5938 $4.68 POL <0.01% $0.395268 11.5791 $4.58 POL <0.01% $1 4.5411 $4.55 POL <0.01% $0.048941 90.917 $4.45 POL <0.01% $0.004845 901.2018 $4.37 POL <0.01% $0.213665 20.0481 $4.28 POL <0.01% $0.005253 806.8082 $4.24 POL <0.01% $0.000393 10,741.6056 $4.22 POL <0.01% $0.009048 459.2901 $4.16 POL <0.01% $4.07 1.0113 $4.12 POL <0.01% $0.005135 799.7594 $4.11 POL <0.01% $1.6 2.5053 $4.01 POL <0.01% $0.006502 611.6503 $3.98 POL <0.01% <$0.000001 65,766,670.6724 $3.96 POL <0.01% $1.08 3.6059 $3.89 POL <0.01% $1.53 2.5271 $3.87 POL <0.01% $154.99 0.0248 $3.84 POL <0.01% $0.007843 481.5821 $3.78 POL <0.01% $0.999944 3.7675 $3.77 POL <0.01% $0.153153 23.8677 $3.66 POL <0.01% $0.00061 5,980.0876 $3.65 POL <0.01% $0.000038 93,312.979 $3.58 POL <0.01% $0.005295 673.4763 $3.57 POL <0.01% <$0.000001 163,994,521.2472 $3.44 POL <0.01% $0.000007 478,128.2236 $3.23 POL <0.01% $0.160935 19.9598 $3.21 POL <0.01% $0.906862 3.522 $3.19 POL <0.01% $0.001241 2,492.7597 $3.09 POL <0.01% $0.006534 465.9209 $3.04 POL <0.01% $0.00329 884.5883 $2.91 POL <0.01% $0.019228 150.6022 $2.9 POL <0.01% $0.025795 107.5756 $2.77 POL <0.01% $4.19 0.661 $2.77 POL <0.01% $0.001319 2,066.0786 $2.72 POL <0.01% $258 0.0103 $2.65 POL <0.01% $0.058439 44.6348 $2.61 POL <0.01% $0.059709 42.8751 $2.56 POL <0.01% $256.78 0.00993112 $2.55 POL <0.01% <$0.000001 273,534,094.2042 $2.52 POL <0.01% $0.694333 3.6067 $2.5 POL <0.01% $0.226047 11 $2.49 POL <0.01% $0.997726 2.4897 $2.48 POL <0.01% $0.097724 25.2495 $2.47 POL <0.01% $0.008406 290.8379 $2.44 POL <0.01% $2,157.19 0.00110546 $2.38 POL <0.01% $0.002612 904.8447 $2.36 POL <0.01% $241.69 0.00974153 $2.35 POL <0.01% $0.000053 42,875.209 $2.28 POL <0.01% $0.000468 4,730.5038 $2.22 POL <0.01% $1.05 2.0596 $2.17 POL <0.01% $0.014016 153.0693 $2.15 POL <0.01% $4.28 0.498 $2.13 POL <0.01% $0.44895 4.7246 $2.12 POL <0.01% $0.002859 715.4341 $2.05 POL <0.01% $0.145027 14.0547 $2.04 POL <0.01% $0.956203 2.0623 $1.97 POL <0.01% $0.001898 973.3635 $1.85 POL <0.01% $0.001558 1,167.844 $1.82 POL <0.01% $0.000291 6,207.5219 $1.8 POL <0.01% $0.001024 1,743.5437 $1.79 POL <0.01% $0.000415 4,214.3094 $1.75 POL <0.01% $0.063929 26.5068 $1.69 POL <0.01% $0.309966 4.9767 $1.54 POL <0.01% $0.005966 258.4928 $1.54 POL <0.01% $0.112502 13.5595 $1.53 POL <0.01% $0.016405 91.8604 $1.51 POL <0.01% $0.007523 197.0706 $1.48 POL <0.01% $0.000007 217,011.3081 $1.47 POL <0.01% $0.526188 2.7948 $1.47 POL <0.01% $0.002282 605.7069 $1.38 POL <0.01% $0.980836 1.3847 $1.36 POL <0.01% $0.368608 3.6313 $1.34 POL <0.01% $1.35 0.9555 $1.29 POL <0.01% $0.00158 811.9444 $1.28 POL <0.01% $0.001143 1,107.7168 $1.27 POL <0.01% $0.010712 117.8237 $1.26 POL <0.01% $0.244739 5.0153 $1.23 POL <0.01% $1.22 1 $1.22 POL <0.01% $0.00128 922.5859 $1.18 POL <0.01% $0.000003 447,416.4778 $1.15 POL <0.01% $0.000954 1,184.2083 $1.13 POL <0.01% $0.655805 1.684 $1.1 POL <0.01% $0.025027 43.6524 $1.09 POL <0.01% $0.016505 66.025 $1.09 POL <0.01% $0.523001 1.9509 $1.02 POL <0.01% $2,627.47 0.00038785 $1.02 POL <0.01% $0.048724 20.4887 $0.9982 POL <0.01% $0.70249 1.4206 $0.9979 POL <0.01% $0.715773 1.3512 $0.9671 POL <0.01% $0.000999 965.9502 $0.9652 POL <0.01% $0.005228 183.8442 $0.9611 POL <0.01% $0.41354 2.2452 $0.9284 POL <0.01% $1.21 0.7603 $0.9199 POL <0.01% $0.342786 2.542 $0.8713 POL <0.01% $0.000213 4,041.5662 $0.8616 POL <0.01% $0.145027 5.8254 $0.8448 POL <0.01% $4.67 0.179 $0.8361 POL <0.01% $0.065878 12.2984 $0.8101 POL <0.01% $0.01549 52.0252 $0.8058 POL <0.01% $0.000123 6,514.2723 $0.8036 POL <0.01% $0.000965 817.727 $0.7891 POL <0.01% $0.164053 4.7007 $0.7711 POL <0.01% $0.015371 49.7591 $0.7648 POL <0.01% $65.44 0.0116 $0.7578 POL <0.01% $0.292616 2.5656 $0.7507 POL <0.01% $0.000275 2,725.6694 $0.7488 POL <0.01% $0.009228 80.9638 $0.7471 POL <0.01% $0.000053 14,049.1519 $0.738 POL <0.01% $1.19 0.6186 $0.736 POL <0.01% $0.001681 433.8534 $0.7292 POL <0.01% $0.000547 1,322.3785 $0.7238 POL <0.01% $1 0.7187 $0.7194 POL <0.01% $0.155335 4.6309 $0.7193 POL <0.01% $0.001087 644.5618 $0.7005 POL <0.01% $0.145832 4.5747 $0.6671 POL <0.01% $0.059675 11.096 $0.6621 POL <0.01% $0.008039 80.2506 $0.6451 POL <0.01% $97,691 0.00000657 $0.6418 POL <0.01% $0.368261 1.7076 $0.6288 POL <0.01% $0.174741 3.5636 $0.6227 POL <0.01% $0.000658 941.8123 $0.6196 POL <0.01% $0.037348 16.2515 $0.6069 POL <0.01% $0.020798 29.0628 $0.6044 POL <0.01% $0.000959 630.0976 $0.6041 POL <0.01% $0.005299 110.3154 $0.5845 POL <0.01% $0.017885 32.1574 $0.5751 POL <0.01% $7.6 0.0735 $0.5585 POL <0.01% $0.00533 102.4982 $0.5462 POL <0.01% $0.039859 13.3411 $0.5317 POL <0.01% $0.794576 0.664 $0.5276 POL <0.01% $0.024861 21.0087 $0.5222 POL <0.01% $0.006328 78.6328 $0.4976 POL <0.01% $0.030148 16.4803 $0.4968 POL <0.01% $1 0.49 $0.4904 POL <0.01% $0.021568 22.5646 $0.4866 POL <0.01% $0.001619 293.3072 $0.4749 POL <0.01% $15.77 0.03 $0.4732 POL <0.01% $0.011926 39.5319 $0.4714 POL <0.01% $0.000001 426,091.8082 $0.4687 POL <0.01% $0.000155 3,011.8001 $0.4662 POL <0.01% $0.106704 4.2538 $0.4538 POL <0.01% $0.017371 25.2854 $0.4392 POL <0.01% $1.95 0.2237 $0.4362 POL <0.01% $3.03 0.1394 $0.4224 POL <0.01% $0.228271 1.7816 $0.4066 POL <0.01% $4,317.79 0.00009329 $0.4028 POL <0.01% $1.11 0.3624 $0.4023 POL <0.01% $0.824114 0.4837 $0.3986 POL <0.01% $0.013356 27.8643 $0.3721 POL <0.01% $0.422353 0.8812 $0.3721 POL <0.01% $1.14 0.3254 $0.372 POL <0.01% $0.000434 853.3732 $0.3701 POL <0.01% $0.015533 23.3308 $0.3623 POL <0.01% $0.000559 632.6163 $0.3535 POL <0.01% $0.313834 1.1236 $0.3526 POL <0.01% $12,267.8 0.00002873 $0.3525 POL <0.01% $0.002892 121.7583 $0.352 POL <0.01% $0.006365 54.9599 $0.3498 POL <0.01% $0.020265 17.0732 $0.3459 POL <0.01% $1.88 0.182 $0.3421 POL <0.01% $0.145844 2.2774 $0.3321 POL <0.01% $0.058777 5.6389 $0.3314 POL <0.01% $0.00012 2,657.4111 $0.3189 POL <0.01% $2.09 0.1479 $0.3091 POL <0.01% $27.11 0.0112 $0.3032 POL <0.01% $2.27 0.1317 $0.2989 POL <0.01% $97,881 0.00000302 $0.2956 POL <0.01% $0.000233 1,243.7738 $0.2896 POL <0.01% $0.994004 0.2793 $0.2776 POL <0.01% <$0.000001 19,754,412.462 $0.2745 POL <0.01% $0.07324 3.7296 $0.2731 POL <0.01% $1.05 0.2526 $0.2644 POL <0.01% $0.000609 431.5939 $0.2629 POL <0.01% $1.2 0.2151 $0.2581 POL <0.01% $3,857.39 0.00006574 $0.2535 POL <0.01% $0.092782 2.6551 $0.2463 POL <0.01% $0.002421 101.5407 $0.2458 POL <0.01% $0.010222 23.8359 $0.2436 POL <0.01% $0.012525 18.3064 $0.2292 POL <0.01% $1.38 0.1617 $0.2231 POL <0.01% $0.388624 0.5727 $0.2225 POL <0.01% $0.002002 108.6022 $0.2173 POL <0.01% $0.639042 0.3377 $0.2158 POL <0.01% $0.00022 959.0151 $0.2106 POL <0.01% $0.017342 12.0442 $0.2088 POL <0.01% $0.005176 39.9393 $0.2067 POL <0.01% $49.66 0.00408616 $0.2029 POL <0.01% $0.003646 54.9515 $0.2003 POL <0.01% $0.001491 132.6878 $0.1978 POL <0.01% $0.347967 0.5629 $0.1958 POL <0.01% $0.000365 527.6255 $0.1925 POL <0.01% $6.85 0.0281 $0.1922 POL <0.01% $0.47044 0.3959 $0.1862 POL <0.01% $0.004536 39.441 $0.1789 POL <0.01% $0.987205 0.1759 $0.1736 POL <0.01% $7.14 0.0242 $0.1728 POL <0.01% $79.93 0.00216035 $0.1726 POL <0.01% $4,186.33 0.00003764 $0.1575 POL <0.01% $0.748174 0.2086 $0.156 POL <0.01% $0.001165 132.2431 $0.154 POL <0.01% $0.790291 0.188 $0.1486 POL <0.01% $0.000959 152.8534 $0.1465 POL <0.01% $0.004589 28.8296 $0.1323 POL <0.01% $0.000693 180.0792 $0.1248 POL <0.01% $0.276527 0.4422 $0.1222 POL <0.01% $0.015068 7.9881 $0.1203 POL <0.01% $1 0.1194 $0.1196 POL <0.01% $0.010844 10.7203 $0.1162 POL <0.01% $0.010031 10.6363 $0.1066 POL <0.01% $0.012833 8.2411 $0.1057 POL <0.01% $0.006694 15.6854 $0.105 POL <0.01% $0.000003 37,468.0451 $0.1045 POL <0.01% $22.8 0.00442148 $0.1008 POL <0.01% $0.037185 2.693 $0.1001 ETH 15.81% $3,875.5 5.0318 $19,500.67 ETH 0.56% <$0.000001 5,401,179,268.262 $688.81 ETH 0.53% $1.34 483.6218 $648.05 ETH 0.51% $2.51 251.3268 $630.83 ETH 0.41% $0.000001 442,539,935.3562 $500.07 ETH 0.38% $1 472.6274 $473.1 ETH 0.37% $1 458.8739 $459.79 ETH 0.30% $0.001971 187,205.5926 $368.94 ETH 0.27% $3,847.74 0.0875 $336.61 ETH 0.27% $0.000022 15,519,533.2841 $336.15 ETH 0.24% $0.005938 49,002.0269 $290.95 ETH 0.21% $0.923795 283.1584 $261.58 ETH 0.21% <$0.000001 3,536,660,490.0411 $254.11 ETH 0.20% $1.87 135.1918 $252.81 ETH 0.19% $713.73 0.3347 $238.88 ETH 0.17% $0.000025 8,465,509.1037 $210.63 ETH 0.17% $1.85 110.6782 $204.37 ETH 0.16% $97,238 0.00206229 $200.53 ETH 0.16% $0.006514 30,722.7863 $200.13 ETH 0.16% $0.052283 3,773.5066 $197.29 ETH 0.16% $257.52 0.7527 $193.83 ETH 0.14% $0.000103 1,738,141.6803 $178.49 ETH 0.14% <$0.000001 2,879,487,451.5181 $172.32 ETH 0.14% $7.82 22.0018 $172.15 ETH 0.14% $0.707778 237.2447 $167.92 ETH 0.13% $239.98 0.6785 $162.83 ETH 0.13% $0.015715 10,341.1336 $162.51 ETH 0.12% $0.06658 2,280.219 $151.82 ETH 0.12% $0.000031 4,866,340.8143 $150.81 ETH 0.12% $0.666797 224.6639 $149.81 ETH 0.12% $0.578194 255.567 $147.77 ETH 0.12% $1.05 134.6123 $141.87 ETH 0.11% $0.314967 442.0826 $139.24 ETH 0.11% $0.270545 507.9249 $137.42 ETH 0.11% $117.18 1.1614 $136.09 ETH 0.11% $1.1 123.958 $135.9 ETH 0.11% $0.000008 15,958,361.8994 $133.65 ETH 0.11% $0.121981 1,080.1709 $131.76 ETH 0.11% $0.074338 1,765.156 $131.22 ETH 0.10% $3,854.34 0.0321 $123.87 ETH 0.10% $4,318.82 0.0282 $121.68 ETH 0.10% <$0.000001 438,744,246.2683 $120.25 ETH 0.10% $0.067843 1,769.3778 $120.04 ETH 0.09% $1.47 76.8454 $113.12 ETH 0.09% $0.045586 2,479.836 $113.05 ETH 0.09% $1.34 84.3327 $113.01 ETH 0.09% $7.98 13.8244 $110.32 ETH 0.09% $0.080494 1,340.3953 $107.89 ETH 0.09% $0.014654 7,337.219 $107.52 ETH 0.09% $0.000164 650,137.5599 $106.61 ETH 0.08% $0.008891 11,783.0435 $104.76 ETH 0.08% $1.34 77.7112 $104.13 ETH 0.08% $0.00097 107,149.9606 $103.96 ETH 0.08% $0.000566 182,259.2382 $103.14 ETH 0.08% $0.769159 131.123 $100.85 ETH 0.08% $1.74 57.4087 $99.89 ETH 0.08% $0.432079 225.505 $97.44 ETH 0.08% $0.688437 140.9572 $97.04 ETH 0.08% $0.073199 1,316.8854 $96.39 ETH 0.08% $142.69 0.6603 $94.22 ETH 0.08% $0.999595 93.9221 $93.88 ETH 0.08% $0.030581 3,064.1091 $93.7 ETH 0.08% $0.007214 12,880.0331 $92.92 ETH 0.07% $1 92.1824 $92.37 ETH 0.07% $0.008834 10,363.2673 $91.55 ETH 0.07% $0.722561 122.4345 $88.47 ETH 0.07% $0.423081 206.0137 $87.16 ETH 0.07% $0.245684 338.1564 $83.08 ETH 0.07% $0.000006 13,877,137.063 $81.04 ETH 0.07% $0.00969 8,341.7567 $80.83 ETH 0.06% $0.870026 89.4954 $77.86 ETH 0.06% $2.14 36.2415 $77.56 ETH 0.06% $0.23152 326.3558 $75.56 ETH 0.06% $0.378606 196.932 $74.56 ETH 0.06% $0.03068 2,394.0619 $73.45 ETH 0.06% $0.004963 14,796.7893 $73.43 ETH 0.06% <$0.000001 19,788,278,948,680.582 $73.42 ETH 0.06% $8.94 8.146 $72.84 ETH 0.06% $4.64 15.638 $72.56 ETH 0.06% $26.77 2.6339 $70.51 ETH 0.06% $0.067377 1,038.4996 $69.97 ETH 0.06% $0.693447 98.0749 $68.01 ETH 0.05% $0.000395 170,548.0878 $67.32 ETH 0.05% $0.995907 66.6557 $66.38 ETH 0.05% $0.972247 67.6068 $65.73 ETH 0.05% $0.031786 2,066.4998 $65.69 ETH 0.05% $59.01 1.1119 $65.61 ETH 0.05% $6.64 9.8382 $65.33 ETH 0.05% $0.016288 3,925.0084 $63.93 ETH 0.05% $0.044624 1,421.8115 $63.45 ETH 0.05% $0.659161 96.218 $63.42 ETH 0.05% $0.025889 2,435.0544 $63.04 ETH 0.05% $1.87 33.1109 $61.92 ETH 0.05% $0.05347 1,157.3465 $61.88 ETH 0.05% $2.22 27.7726 $61.66 ETH 0.05% $0.000667 92,124.8907 $61.48 ETH 0.05% $1.96 31.2229 $61.2 ETH 0.05% $0.028174 2,169.7105 $61.13 ETH 0.05% $0.000238 252,053.0886 $60.05 ETH 0.05% $1 58.74 $58.74 ETH 0.05% $0.341811 169.6832 $58 ETH 0.05% <$0.000001 256,832,563.5524 $57.76 ETH 0.05% $0.317065 181.9726 $57.7 ETH 0.05% $0.241316 238.9692 $57.67 ETH 0.05% $97,738 0.0005899 $57.66 ETH 0.05% $0.000002 29,306,460.6854 $57.27 ETH 0.05% $0.978992 58.2101 $56.99 ETH 0.05% <$0.000001 29,365,053,379.4436 $56.67 ETH 0.05% $0.176703 317.8185 $56.16 ETH 0.05% $0.447283 124.9454 $55.89 ETH 0.04% $0.270094 203.8134 $55.05 ETH 0.04% $0.089682 604.6911 $54.23 ETH 0.04% $66.56 0.8146 $54.22 ETH 0.04% $0.092891 583.6904 $54.22 ETH 0.04% $8.1 6.586 $53.34 ETH 0.04% $6.41 8.185 $52.47 ETH 0.04% $0.340113 153.8887 $52.34 ETH 0.04% $37.98 1.3692 $52 ETH 0.04% $0.008392 6,119.2603 $51.35 ETH 0.04% $1.52 33.5746 $51.03 ETH 0.04% $0.034801 1,439.866 $50.11 ETH 0.04% $33.95 1.4614 $49.61 ETH 0.04% $0.058128 835.32 $48.56 ETH 0.04% $0.812311 57.5085 $46.71 ETH 0.04% $0.000204 227,927.9022 $46.5 ETH 0.04% $6.92 6.6633 $46.11 ETH 0.04% $0.154025 298.6338 $46 ETH 0.04% $0.007572 6,023.1541 $45.61 ETH 0.04% $0.531254 84.4759 $44.88 ETH 0.04% $1.06 42.077 $44.69 ETH 0.04% $0.830152 53.795 $44.66 ETH 0.04% $0.000911 48,361.8016 $44.07 ETH 0.04% $0.188462 233.3116 $43.97 ETH 0.03% $0.000246 173,923.2628 $42.82 ETH 0.03% $0.018529 2,275.2061 $42.16 ETH 0.03% $6.62 6.3546 $42.08 ETH 0.03% $0.202782 206.4084 $41.86 ETH 0.03% $0.004678 8,938.0824 $41.81 ETH 0.03% $0.028966 1,441.9835 $41.77 ETH 0.03% $1.89 21.9021 $41.39 ETH 0.03% $0.996279 41.4824 $41.33 ETH 0.03% $154.66 0.2671 $41.31 ETH 0.03% $0.02415 1,698.0249 $41.01 ETH 0.03% $3.71 10.9232 $40.53 ETH 0.03% $0.764426 52.4851 $40.12 ETH 0.03% $0.911943 43.5864 $39.75 ETH 0.03% $2.05 19.2738 $39.51 ETH 0.03% $4.07 9.5938 $39.05 ETH 0.03% $1 38.3653 $38.46 ETH 0.03% $3.74 10.2536 $38.35 ETH 0.03% $0.116882 324.5082 $37.93 ETH 0.03% $101.95 0.3538 $36.07 ETH 0.03% $1.01 35.3958 $35.57 ETH 0.03% $0.840351 42.0492 $35.34 ETH 0.03% <$0.000001 76,630,570.7736 $34.48 ETH 0.03% $0.457906 75.2149 $34.44 ETH 0.03% $0.524553 63.7898 $33.46 ETH 0.03% $1.15 29.0269 $33.38 ETH 0.03% <$0.000001 191,621,136.4947 $33.25 ETH 0.03% $19.86 1.6683 $33.13 ETH 0.03% $0.65377 50.6178 $33.09 ETH 0.03% $0.46371 70.0659 $32.49 ETH 0.03% $0.00001 3,122,679.2337 $32.35 ETH 0.03% $0.053186 606 $32.23 ETH 0.03% $5.33 5.8415 $31.14 ETH 0.02% $0.905281 33.8636 $30.66 ETH 0.02% $0.000001 33,150,718.4543 $30.65 ETH 0.02% $0.001467 20,430.4237 $29.96 ETH 0.02% $0.050934 574.1337 $29.24 ETH 0.02% $0.194508 148.0447 $28.8 ETH 0.02% $96,356 0.00029133 $28.07 ETH 0.02% $1 27.5503 $27.63 ETH 0.02% $0.310363 89.0164 $27.63 ETH 0.02% $0.693082 39.5177 $27.39 ETH 0.02% $0.455366 57.8357 $26.34 ETH 0.02% $0.058669 446.5265 $26.2 ETH 0.02% $0.995646 26.1214 $26.01 ETH 0.02% $0.741313 34.9457 $25.91 ETH 0.02% $0.020942 1,232.7902 $25.82 ETH 0.02% $378.86 0.068 $25.77 ETH 0.02% $0.000005 5,344,004.4626 $25.54 ETH 0.02% $20.79 1.2031 $25.01 ETH 0.02% $1.06 23.2988 $24.67 ETH 0.02% $3,962.09 0.00617285 $24.46 ETH 0.02% $242.04 0.0983 $23.79 ETH 0.02% $288.83 0.0822 $23.73 ETH 0.02% $0.002387 9,782.5052 $23.35 ETH 0.02% $0.076977 302.7808 $23.31 ETH 0.02% $0.003779 6,100.6002 $23.05 ETH 0.02% $1.28 17.6511 $22.59 ETH 0.02% $0.369828 60.2828 $22.29 ETH 0.02% $15.59 1.4174 $22.1 ETH 0.02% $0.31407 68.0482 $21.37 ETH 0.02% $46.66 0.4499 $20.99 ETH 0.02% $2.07 10.111 $20.93 ETH 0.02% <$0.000001 2,225,081,330.5233 $20.85 ETH 0.02% $4.77 4.3538 $20.77 ETH 0.02% <$0.000001 675,539,864,954,565.88 $20.67 ETH 0.02% $1.01 20.3584 $20.46 ETH 0.02% $0.007158 2,788.8931 $19.96 ETH 0.02% $0.000866 22,923.757 $19.86 ETH 0.02% $3.03 6.4631 $19.58 ETH 0.02% $0.00085 22,784.7371 $19.38 ETH 0.02% $0.998721 19.3663 $19.34 ETH 0.02% $0.000052 366,808.3237 $19.19 ETH 0.02% $15.78 1.2128 $19.14 ETH 0.02% $22.46 0.8334 $18.72 ETH 0.02% $8.03 2.3134 $18.58 ETH 0.01% $0.031786 580.1064 $18.44 ETH 0.01% $0.208222 88.0906 $18.34 ETH 0.01% $21.49 0.848 $18.22 ETH 0.01% $0.364801 49.1818 $17.94 ETH 0.01% $0.000136 131,425.2082 $17.87 ETH 0.01% $1.15 15.5086 $17.83 ETH 0.01% $2.39 7.4616 $17.83 ETH 0.01% $0.635196 27.532 $17.49 ETH 0.01% $0.052697 327.4796 $17.26 ETH 0.01% $0.001307 13,070.1068 $17.08 ETH 0.01% $33.31 0.5083 $16.93 ETH 0.01% $0.132159 127.0834 $16.8 ETH 0.01% $0.084942 190.4067 $16.17 ETH 0.01% $0.026041 618.2866 $16.1 ETH 0.01% $0.050615 316.2181 $16.01 ETH 0.01% $3.98 4.0095 $15.96 ETH 0.01% $1.96 8.1137 $15.93 ETH 0.01% $0.281375 56.1438 $15.8 ETH 0.01% $0.013876 1,131.0471 $15.69 ETH 0.01% $0.001777 8,752.758 $15.55 ETH 0.01% $0.177851 86.8103 $15.44 ETH 0.01% $0.170849 90.0651 $15.39 ETH 0.01% $0.000003 4,890,772.1631 $15.31 ETH 0.01% $0.001425 10,649.3344 $15.18 ETH 0.01% $0.778004 19.3197 $15.03 ETH 0.01% $0.001435 10,304.3884 $14.78 ETH 0.01% $0.002872 5,095.3493 $14.63 ETH 0.01% $0.706846 20.6588 $14.6 ETH 0.01% $0.000227 64,279.4919 $14.59 ETH 0.01% $0.48 30.3726 $14.58 ETH 0.01% $0.000001 12,446,274.5121 $14.56 ETH 0.01% $0.001508 9,455.2348 $14.25 ETH 0.01% $2.79 4.9918 $13.93 ETH 0.01% $160.76 0.0866 $13.92 ETH 0.01% $0.244576 56.4798 $13.81 ETH 0.01% $26.51 0.5138 $13.62 ETH 0.01% $0.040805 332.8391 $13.58 ETH 0.01% $97,623 0.00013895 $13.56 ETH 0.01% $0.538484 25.1323 $13.53 ETH 0.01% $0.078104 169.06 $13.2 ETH 0.01% $4,032.65 0.00324431 $13.08 ETH 0.01% $0.054839 230.5309 $12.64 ETH 0.01% $153.2 0.0817 $12.51 ETH 0.01% $0.006126 2,039.0074 $12.49 ETH 0.01% $1.71 7.2754 $12.44 ETH <0.01% $3,964.11 0.00307632 $12.19 ETH <0.01% $0.020955 581.7548 $12.19 ETH <0.01% $0.000186 64,898.1727 $12.09 ETH <0.01% $0.006698 1,788.0681 $11.98 ETH <0.01% $0.914092 13.087 $11.96 ETH <0.01% $0.755338 15.5721 $11.76 ETH <0.01% $0.984707 11.7804 $11.6 ETH <0.01% $0.006556 1,750.23 $11.47 ETH <0.01% $4.26 2.6547 $11.3 ETH <0.01% $0.743171 15.1914 $11.29 ETH <0.01% <$0.000001 46,763,040.8487 $11.18 ETH <0.01% $0.026523 420.7588 $11.16 ETH <0.01% $4,063.25 0.00270791 $11 ETH <0.01% $5,276.13 0.0020767 $10.96 ETH <0.01% $0.047172 232.0914 $10.95 ETH <0.01% $1.13 9.6881 $10.95 ETH <0.01% $0.565915 19.0108 $10.76 ETH <0.01% $0.003894 2,759.0578 $10.74 ETH <0.01% $10.34 1.0361 $10.71 ETH <0.01% $1.75 6.0017 $10.5 ETH <0.01% <$0.000001 590,349,532.8158 $10.48 ETH <0.01% $1.75 5.911 $10.34 ETH <0.01% $4.22 2.431 $10.27 ETH <0.01% $0.044234 228.7108 $10.12 ETH <0.01% $0.000006 1,702,868.9229 $10.12 ETH <0.01% $0.194774 51.528 $10.04 ETH <0.01% $1.3 7.6901 $10 ETH <0.01% $0.172183 57.649 $9.93 ETH <0.01% <$0.000001 3,059,713,101,797.9541 $9.77 ETH <0.01% $4.04 2.4136 $9.75 ETH <0.01% $0.000098 97,547.7043 $9.55 ETH <0.01% $0.006606 1,437.8784 $9.5 ETH <0.01% $0.535273 17.7357 $9.49 ETH <0.01% $2.14 4.3944 $9.4 ETH <0.01% $3 3.1096 $9.33 ETH <0.01% $0.216341 42.7643 $9.25 ETH <0.01% $0.274481 33.6261 $9.23 ETH <0.01% $1.42 6.4825 $9.21 ETH <0.01% $0.00017 53,876.3684 $9.13 ETH <0.01% $0.015749 577.3614 $9.09 ETH <0.01% $17.73 0.5107 $9.06 ETH <0.01% $0.000002 4,653,994.2576 $8.84 ETH <0.01% $0.005638 1,547.3848 $8.72 ETH <0.01% $0.141855 61.4303 $8.71 ETH <0.01% $0.002586 3,350.2236 $8.66 ETH