Overview
S Balance
0 S
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
Zap
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "./base/Controllable.sol"; import "./libs/ConstantsLib.sol"; import "../interfaces/IVault.sol"; import "../interfaces/IStrategy.sol"; import "../interfaces/IZap.sol"; /// @title Implementation of ZAP feature in the Stability platform. /// ZAP feature simplifies the DeFi investment process. /// With ZAP users can provide liquidity to DeXs and liquidity mining/management vaults by single asset. /// In this case, an asset is swapped for the pool assets in the required proportion. /// The swap is carried out through one of the DeX aggregators allowed in the platform. /// The platform architecture makes it possible to use ZAP for all created vaults. /// @author Alien Deployer (https://github.com/a17) /// @author JodsMigel (https://github.com/JodsMigel) contract Zap is Controllable, ReentrancyGuardUpgradeable, IZap { using SafeERC20 for IERC20; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @inheritdoc IControllable string public constant VERSION = "1.0.3"; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INITIALIZATION */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ function initialize(address platform_) public initializer { __Controllable_init(platform_); __ReentrancyGuard_init(); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* USER ACTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @inheritdoc IZap // slither-disable-next-line calls-loop function deposit( address vault, address tokenIn, uint amountIn, address agg, bytes[] memory swapData, uint minSharesOut, address receiver ) external nonReentrant { if (amountIn == 0) { revert IControllable.IncorrectZeroArgument(); } if (!IPlatform(platform()).isAllowedDexAggregatorRouter(agg)) { revert NotAllowedDexAggregator(agg); } if (receiver == address(0)) { receiver = msg.sender; } IERC20(tokenIn).safeTransferFrom(msg.sender, address(this), amountIn); _approveIfNeeds(tokenIn, amountIn, agg); address strategy = address(IVault(vault).strategy()); address[] memory assets = IStrategy(strategy).assets(); uint len = assets.length; uint[] memory depositAmounts = new uint[](len); // nosemgrep for (uint i; i < len; ++i) { if (tokenIn == assets[i]) { continue; } if (swapData[i].length == 0) { continue; } //slither-disable-next-line low-level-calls (bool success, bytes memory result) = agg.call(swapData[i]); if (!success) { revert AggSwapFailed(string(result)); } } // nosemgrep for (uint i; i < len; ++i) { // slither-disable-next-line calls-loop depositAmounts[i] = IERC20(assets[i]).balanceOf(address(this)); _approveIfNeeds(assets[i], depositAmounts[i], vault); } IVault(vault).depositAssets(assets, depositAmounts, minSharesOut, receiver); _sendAllRemaining(tokenIn, assets, IStrategy(strategy).underlying()); } /// @inheritdoc IZap // slither-disable-next-line calls-loop function withdraw( address vault, address tokenOut, address agg, bytes[] memory swapData, uint sharesToBurn, uint minAmountOut ) external nonReentrant { if (!IPlatform(platform()).isAllowedDexAggregatorRouter(agg)) { revert NotAllowedDexAggregator(agg); } uint len = swapData.length; address strategy = address(IVault(vault).strategy()); address[] memory assets = IStrategy(strategy).assets(); uint[] memory amountsOut = IVault(vault).withdrawAssets(assets, sharesToBurn, new uint[](len), address(this), msg.sender); // nosemgrep for (uint i; i < len; ++i) { if (tokenOut == assets[i]) { continue; } _approveIfNeeds(assets[i], amountsOut[i], agg); // slither-disable-next-line low-level-calls (bool success, bytes memory result) = agg.call(swapData[i]); if (!success) { revert AggSwapFailed(string(result)); } } uint b = IERC20(tokenOut).balanceOf(address(this)); if (b < minAmountOut) { revert Slippage(b, minAmountOut); } _sendAllRemaining(tokenOut, assets, IStrategy(strategy).underlying()); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* VIEW FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @inheritdoc IZap function getDepositSwapAmounts( address vault, address tokenIn, uint amountIn ) external view returns (address[] memory tokensOut, uint[] memory swapAmounts) { address strategy = address(IVault(vault).strategy()); tokensOut = IStrategy(strategy).assets(); uint len = tokensOut.length; swapAmounts = new uint[](len); uint[] memory proportions = IStrategy(strategy).getAssetsProportions(); uint amountInUsed = 0; // nosemgrep for (uint i; i < len; ++i) { if (tokensOut[i] == tokenIn) { amountInUsed += amountIn * proportions[i] / 1e18; continue; } if (i < len - 1) { swapAmounts[i] = amountIn * proportions[i] / 1e18; amountInUsed += swapAmounts[i]; } else { swapAmounts[i] = amountIn - amountInUsed; } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL LOGIC */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @notice Make infinite approve of {token} to {spender} if the approved amount is less than {amount} /// @dev Should NOT be used for third-party pools function _approveIfNeeds(address token, uint amount, address spender) internal { // slither-disable-next-line calls-loop if (IERC20(token).allowance(address(this), spender) < amount) { IERC20(token).forceApprove(spender, type(uint).max); } } function _sendAllRemaining(address tokenIn, address[] memory strategyAssets, address underlying) internal { _sendRemaining(tokenIn); uint len = strategyAssets.length; // nosemgrep for (uint i; i < len; ++i) { _sendRemaining(strategyAssets[i]); } if (underlying != address(0)) { _sendRemaining(underlying); } } function _sendRemaining(address token) internal { uint bal = IERC20(token).balanceOf(address(this)); if (bal > 0) { IERC20(token).safeTransfer(msg.sender, bal); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../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; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @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); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "../libs/SlotsLib.sol"; import "../../interfaces/IControllable.sol"; import "../../interfaces/IPlatform.sol"; /// @dev Base core contract. /// It store an immutable platform proxy address in the storage and provides access control to inherited contracts. /// @author Alien Deployer (https://github.com/a17) /// @author 0xhokugava (https://github.com/0xhokugava) abstract contract Controllable is Initializable, IControllable, ERC165 { using SlotsLib for bytes32; string public constant CONTROLLABLE_VERSION = "1.0.0"; bytes32 internal constant _PLATFORM_SLOT = bytes32(uint(keccak256("eip1967.controllable.platform")) - 1); bytes32 internal constant _CREATED_BLOCK_SLOT = bytes32(uint(keccak256("eip1967.controllable.created_block")) - 1); /// @dev Prevent implementation init constructor() { _disableInitializers(); } /// @notice Initialize contract after setup it as proxy implementation /// Save block.timestamp in the "created" variable /// @dev Use it only once after first logic setup /// @param platform_ Platform address //slither-disable-next-line naming-convention function __Controllable_init(address platform_) internal onlyInitializing { if (platform_ == address(0) || IPlatform(platform_).multisig() == address(0)) { revert IncorrectZeroArgument(); } SlotsLib.set(_PLATFORM_SLOT, platform_); // syntax for forge coverage _CREATED_BLOCK_SLOT.set(block.number); emit ContractInitialized(platform_, block.timestamp, block.number); } modifier onlyGovernance() { _requireGovernance(); _; } modifier onlyMultisig() { _requireMultisig(); _; } modifier onlyGovernanceOrMultisig() { _requireGovernanceOrMultisig(); _; } modifier onlyOperator() { _requireOperator(); _; } modifier onlyFactory() { _requireFactory(); _; } // ************* SETTERS/GETTERS ******************* /// @inheritdoc IControllable function platform() public view override returns (address) { return _PLATFORM_SLOT.getAddress(); } /// @inheritdoc IControllable function createdBlock() external view override returns (uint) { return _CREATED_BLOCK_SLOT.getUint(); } /// @inheritdoc IERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IControllable).interfaceId || super.supportsInterface(interfaceId); } function _requireGovernance() internal view { if (IPlatform(platform()).governance() != msg.sender) { revert NotGovernance(); } } function _requireMultisig() internal view { if (!IPlatform(platform()).isOperator(msg.sender)) { revert NotMultisig(); } } function _requireGovernanceOrMultisig() internal view { IPlatform _platform = IPlatform(platform()); // nosemgrep if (_platform.governance() != msg.sender && _platform.multisig() != msg.sender) { revert NotGovernanceAndNotMultisig(); } } function _requireOperator() internal view { if (!IPlatform(platform()).isOperator(msg.sender)) { revert NotOperator(); } } function _requireFactory() internal view { if (IPlatform(platform()).factory() != msg.sender) { revert NotFactory(); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; library ConstantsLib { uint internal constant DENOMINATOR = 100_000; address internal constant DEAD_ADDRESS = 0xdEad000000000000000000000000000000000000; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import "./IStrategy.sol"; /// @notice Vault core interface. /// Derived implementations can be effective for building tokenized vaults with single or multiple underlying liquidity mining position. /// Fungible, static non-fungible and actively re-balancing liquidity is supported, as well as single token liquidity provided to lending protocols. /// Vaults can be used for active concentrated liquidity management and market making. /// @author Jude (https://github.com/iammrjude) /// @author JodsMigel (https://github.com/JodsMigel) interface IVault is IERC165 { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ error NotEnoughBalanceToPay(); error FuseTrigger(); error ExceedSlippage(uint mintToUser, uint minToMint); error ExceedSlippageExactAsset(address asset, uint mintToUser, uint minToMint); error ExceedMaxSupply(uint maxSupply); error NotEnoughAmountToInitSupply(uint mintAmount, uint initialShares); error WaitAFewBlocks(); error StrategyZeroDeposit(); error NotSupported(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ event DepositAssets(address indexed account, address[] assets, uint[] amounts, uint mintAmount); event WithdrawAssets( address indexed sender, address indexed owner, address[] assets, uint sharesAmount, uint[] amountsOut ); event HardWorkGas(uint gasUsed, uint gasCost, bool compensated); event DoHardWorkOnDepositChanged(bool oldValue, bool newValue); event MaxSupply(uint maxShares); event VaultName(string newName); event VaultSymbol(string newSymbol); event MintFees( uint vaultManagerReceiverFee, uint strategyLogicReceiverFee, uint ecosystemRevenueReceiverFee, uint multisigReceiverFee ); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* DATA TYPES */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @custom:storage-location erc7201:stability.VaultBase struct VaultBaseStorage { /// @dev Prevents manipulations with deposit and withdraw in short time. /// For simplification we are setup new withdraw request on each deposit/transfer. mapping(address msgSender => uint blockNumber) withdrawRequests; /// @inheritdoc IVault IStrategy strategy; /// @inheritdoc IVault uint maxSupply; /// @inheritdoc IVault uint tokenId; /// @inheritdoc IVault bool doHardWorkOnDeposit; /// @dev Immutable vault type ID string _type; /// @dev Changed ERC20 name string changedName; /// @dev Changed ERC20 symbol string changedSymbol; } /// @title Vault Initialization Data /// @notice Data structure containing parameters for initializing a new vault. /// @dev This struct is commonly used as a parameter for the `initialize` function in vault contracts. /// @param platform Platform address providing access control, infrastructure addresses, fee settings, and upgrade capability. /// @param strategy Immutable strategy proxy used by the vault. /// @param name ERC20 name for the vault token. /// @param symbol ERC20 symbol for the vault token. /// @param tokenId NFT ID associated with the VaultManager. /// @param vaultInitAddresses Array of addresses used during vault initialization. /// @param vaultInitNums Array of uint values corresponding to initialization parameters. struct VaultInitializationData { address platform; address strategy; string name; string symbol; uint tokenId; address[] vaultInitAddresses; uint[] vaultInitNums; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* VIEW FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @notice Immutable vault type ID function vaultType() external view returns (string memory); /// @return uniqueInitAddresses Return required unique init addresses /// @return uniqueInitNums Return required unique init nums function getUniqueInitParamLength() external view returns (uint uniqueInitAddresses, uint uniqueInitNums); /// @notice Vault type extra data /// @return Vault type color, background color and other extra data function extra() external view returns (bytes32); /// @notice Immutable strategy proxy used by the vault /// @return Linked strategy function strategy() external view returns (IStrategy); /// @notice Max supply of shares in the vault. /// Since the starting share price is $1, this ceiling can be considered as an approximate TVL limit. /// @return Max total supply of vault function maxSupply() external view returns (uint); /// @dev VaultManager token ID. This tokenId earn feeVaultManager provided by Platform. function tokenId() external view returns (uint); /// @dev Trigger doHardwork on invest action. Enabled by default. function doHardWorkOnDeposit() external view returns (bool); /// @dev USD price of share with 18 decimals. /// ONLY FOR OFF-CHAIN USE. /// Not trusted vault share price can be manipulated. /// @return price_ Price of 1e18 shares with 18 decimals precision /// @return trusted True means oracle price, false means AMM spot price function price() external view returns (uint price_, bool trusted); /// @dev USD price of assets managed by strategy with 18 decimals /// ONLY FOR OFF-CHAIN USE. /// Not trusted TVL can be manipulated. /// @return tvl_ Total USD value of final assets in vault /// @return trusted True means TVL calculated based only on oracle prices, false means AMM spot price was used. function tvl() external view returns (uint tvl_, bool trusted); /// @dev Calculation of consumed amounts, shares amount and liquidity/underlying value for provided available amounts of strategy assets /// @param assets_ Assets suitable for vault strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic. /// @param amountsMax Available amounts of assets_ that user wants to invest in vault /// @return amountsConsumed Amounts of strategy assets that can be deposited by providing amountsMax /// @return sharesOut Amount of vault shares that will be minted /// @return valueOut Liquidity value or underlying token amount that will be received by the strategy function previewDepositAssets( address[] memory assets_, uint[] memory amountsMax ) external view returns (uint[] memory amountsConsumed, uint sharesOut, uint valueOut); /// @notice All available data on the latest declared APR (annual percentage rate) /// @return totalApr Total APR of investing money to vault. 18 decimals: 1e18 - +100% per year. /// @return strategyApr Strategy investmnt APR declared on last HardWork. /// @return assetsWithApr Assets with underlying APR /// @return assetsAprs Underlying APR of asset function getApr() external view returns (uint totalApr, uint strategyApr, address[] memory assetsWithApr, uint[] memory assetsAprs); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* WRITE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @notice Write version of previewDepositAssets /// @param assets_ Assets suitable for vault strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic. /// @param amountsMax Available amounts of assets_ that user wants to invest in vault /// @return amountsConsumed Amounts of strategy assets that can be deposited by providing amountsMax /// @return sharesOut Amount of vault shares that will be minted /// @return valueOut Liquidity value or underlying token amount that will be received by the strategy function previewDepositAssetsWrite( address[] memory assets_, uint[] memory amountsMax ) external returns (uint[] memory amountsConsumed, uint sharesOut, uint valueOut); /// @dev Mint fee shares callback /// @param revenueAssets Assets returned by _claimRevenue function that was earned during HardWork /// @param revenueAmounts Assets amounts returned from _claimRevenue function that was earned during HardWork /// Only strategy can call this function hardWorkMintFeeCallback(address[] memory revenueAssets, uint[] memory revenueAmounts) external; /// @dev Deposit final assets (pool assets) to the strategy and minting of vault shares. /// If the strategy interacts with a pool or farms through an underlying token, then it will be minted. /// Emits a {DepositAssets} event with consumed amounts. /// @param assets_ Assets suitable for the strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic. /// @param amountsMax Available amounts of assets_ that user wants to invest in vault /// @param minSharesOut Slippage tolerance. Minimal shares amount which must be received by user. /// @param receiver Receiver of deposit. If receiver is zero address, receiver is msg.sender. function depositAssets( address[] memory assets_, uint[] memory amountsMax, uint minSharesOut, address receiver ) external; /// @dev Burning shares of vault and obtaining strategy assets. /// @param assets_ Assets suitable for the strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic. /// @param amountShares Shares amount for burning /// @param minAssetAmountsOut Slippage tolerance. Minimal amounts of strategy assets that user must receive. /// @return Amount of assets for withdraw. It's related to assets_ one-by-one. function withdrawAssets( address[] memory assets_, uint amountShares, uint[] memory minAssetAmountsOut ) external returns (uint[] memory); /// @dev Burning shares of vault and obtaining strategy assets. /// @param assets_ Assets suitable for the strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic. /// @param amountShares Shares amount for burning /// @param minAssetAmountsOut Slippage tolerance. Minimal amounts of strategy assets that user must receive. /// @param receiver Receiver of assets /// @param owner Owner of vault shares /// @return Amount of assets for withdraw. It's related to assets_ one-by-one. function withdrawAssets( address[] memory assets_, uint amountShares, uint[] memory minAssetAmountsOut, address receiver, address owner ) external returns (uint[] memory); /// @dev Setting of vault capacity /// @param maxShares If totalSupply() exceeds this value, deposits will not be possible function setMaxSupply(uint maxShares) external; /// @dev If activated will call doHardWork on strategy on some deposit actions /// @param value HardWork on deposit is enabled function setDoHardWorkOnDeposit(bool value) external; /// @notice Initialization function for the vault. /// @dev This function is usually called by the Factory during the creation of a new vault. /// @param vaultInitializationData Data structure containing parameters for vault initialization. function initialize(VaultInitializationData memory vaultInitializationData) external; /// @dev Calling the strategy HardWork by operator with optional compensation for spent gas from the vault balance function doHardWork() external; /// @dev Changing ERC20 name of vault function setName(string calldata newName) external; /// @dev Changing ERC20 symbol of vault function setSymbol(string calldata newSymbol) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /// @dev Core interface of strategy logic interface IStrategy is IERC165 { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ event HardWork( uint apr, uint compoundApr, uint earned, uint tvl, uint duration, uint sharePrice, uint[] assetPrices ); event ExtractFees( uint vaultManagerReceiverFee, uint strategyLogicReceiverFee, uint ecosystemRevenueReceiverFee, uint multisigReceiverFee ); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ error NotReadyForHardWork(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* DATA TYPES */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @custom:storage-location erc7201:stability.StrategyBase struct StrategyBaseStorage { /// @inheritdoc IStrategy address vault; /// @inheritdoc IStrategy uint total; /// @inheritdoc IStrategy uint lastHardWork; /// @inheritdoc IStrategy uint lastApr; /// @inheritdoc IStrategy uint lastAprCompound; /// @inheritdoc IStrategy address[] _assets; /// @inheritdoc IStrategy address _underlying; string _id; uint _exchangeAssetIndex; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* VIEW FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Strategy logic string ID function strategyLogicId() external view returns (string memory); /// @dev Extra data /// @return 0-2 bytes - strategy color /// 3-5 bytes - strategy background color /// 6-31 bytes - free function extra() external view returns (bytes32); /// @dev Types of vault that supported by strategy implementation /// @return types Vault type ID strings function supportedVaultTypes() external view returns (string[] memory types); /// @dev Linked vault address function vault() external view returns (address); /// @dev Final assets that strategy invests function assets() external view returns (address[] memory); /// @notice Final assets and amounts that strategy manages function assetsAmounts() external view returns (address[] memory assets_, uint[] memory amounts_); /// @notice Priced invested assets proportions /// @return proportions Proportions of assets with 18 decimals. Min is 0, max is 1e18. function getAssetsProportions() external view returns (uint[] memory proportions); /// @notice Underlying token address /// @dev Can be used for liquidity farming strategies where AMM has fungible liquidity token (Solidly forks, etc), /// for concentrated liquidity tokenized vaults (Gamma, G-UNI etc) and for other needs. /// @return Address of underlying token or zero address if no underlying in strategy function underlying() external view returns (address); /// @dev Balance of liquidity token or liquidity value function total() external view returns (uint); /// @dev Last HardWork time /// @return Timestamp function lastHardWork() external view returns (uint); /// @dev Last APR of earned USD amount registered by HardWork /// ONLY FOR OFF-CHAIN USE. /// Not trusted asset price can be manipulated. /// @return APR with 18 decimals. 1e18 - 100%. function lastApr() external view returns (uint); /// @dev Last APR of compounded assets registered by HardWork. /// Can be used on-chain. /// @return APR with 18 decimals. 1e18 - 100%. function lastAprCompound() external view returns (uint); /// @notice Calculation of consumed amounts and liquidity/underlying value for provided strategy assets and amounts. /// @param assets_ Strategy assets or part of them, if necessary /// @param amountsMax Amounts of specified assets available for investing /// @return amountsConsumed Cosumed amounts of assets when investing /// @return value Liquidity value or underlying token amount minted when investing function previewDepositAssets( address[] memory assets_, uint[] memory amountsMax ) external view returns (uint[] memory amountsConsumed, uint value); /// @notice Write version of previewDepositAssets /// @param assets_ Strategy assets or part of them, if necessary /// @param amountsMax Amounts of specified assets available for investing /// @return amountsConsumed Cosumed amounts of assets when investing /// @return value Liquidity value or underlying token amount minted when investing function previewDepositAssetsWrite( address[] memory assets_, uint[] memory amountsMax ) external returns (uint[] memory amountsConsumed, uint value); /// @notice All strategy revenue (pool fees, farm rewards etc) that not claimed by strategy yet /// @return assets_ Revenue assets /// @return amounts Amounts. Index of asset same as in previous array. function getRevenue() external view returns (address[] memory assets_, uint[] memory amounts); /// @notice Optional specific name of investing strategy, underyling type, setup variation etc /// @return name Empty string or specific name /// @return showInVaultSymbol Show specific in linked vault symbol function getSpecificName() external view returns (string memory name, bool showInVaultSymbol); /// @notice Variants pf strategy initializations with description of money making mechanic. /// As example, if strategy need farm, then number of variations is number of available farms. /// If CAMM strategy have set of available widths (tick ranges), then number of variations is number of available farms. /// If both example conditions are met then total number or variations = total farms * total widths. /// @param platform_ Need this param because method called when strategy implementation is not initialized /// @return variants Descriptions of the strategy for making money /// @return addresses Init strategy addresses. Indexes for each variants depends of copmpared arrays lengths. /// @return nums Init strategy numbers. Indexes for each variants depends of copmpared arrays lengths. /// @return ticks Init strategy ticks. Indexes for each variants depends of copmpared arrays lengths. function initVariants(address platform_) external view returns (string[] memory variants, address[] memory addresses, uint[] memory nums, int24[] memory ticks); /// @notice How does the strategy make money? /// @return Description in free form function description() external view returns (string memory); /// @notice Is HardWork on vault deposits can be enabled function isHardWorkOnDepositAllowed() external view returns (bool); /// @notice Is HardWork can be executed function isReadyForHardWork() external view returns (bool); /// @notice Strategy not need to process revenue on HardWorks function autoCompoundingByUnderlyingProtocol() external view returns (bool); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* WRITE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev A single universal initializer for all strategy implementations. /// @param addresses All addresses that strategy requires for initialization. Min array length is 2. /// addresses[0]: platform (required) /// addresses[1]: vault (required) /// addresses[2]: initStrategyAddresses[0] (optional) /// addresses[3]: initStrategyAddresses[1] (optional) /// addresses[n]: initStrategyAddresses[n - 2] (optional) /// @param nums All uint values that strategy requires for initialization. Min array length is 0. /// @param ticks All int24 values that strategy requires for initialization. Min array length is 0. function initialize(address[] memory addresses, uint[] memory nums, int24[] memory ticks) external; /// @notice Invest strategy assets. Amounts of assets must be already on strategy contract balance. /// Only vault can call this. /// @param amounts Anounts of strategy assets /// @return value Liquidity value or underlying token amount function depositAssets(uint[] memory amounts) external returns (uint value); /// @notice Invest underlying asset. Asset must be already on strategy contract balance. /// Only vault can call this. /// @param amount Amount of underlying asset to invest /// @return amountsConsumed Cosumed amounts of invested assets function depositUnderlying(uint amount) external returns (uint[] memory amountsConsumed); /// @dev For specified amount of shares and assets_, withdraw strategy assets from farm/pool/staking and send to receiver if possible /// Only vault can call this. /// @param assets_ Here we give the user a choice of assets to withdraw if strategy support it /// @param value Part of strategy total value to withdraw /// @param receiver User address /// @return amountsOut Amounts of assets sent to user function withdrawAssets( address[] memory assets_, uint value, address receiver ) external returns (uint[] memory amountsOut); /// @notice Wothdraw underlying invested and send to receiver /// Only vault can call this. /// @param amount Ampunt of underlying asset to withdraw /// @param receiver User of vault which withdraw underlying from the vault function withdrawUnderlying(uint amount, address receiver) external; /// @dev For specified amount of shares, transfer strategy assets from contract balance and send to receiver if possible /// This method is called by vault w/o underlying on triggered fuse mode. /// Only vault can call this. /// @param amount Ampunt of liquidity value that user withdraw /// @param totalAmount Total amount of strategy liquidity /// @param receiver User of vault which withdraw assets /// @return amountsOut Amounts of strategy assets sent to user function transferAssets( uint amount, uint totalAmount, address receiver ) external returns (uint[] memory amountsOut); /// @notice Execute HardWork /// During HardWork strategy claiming revenue and processing it. /// Only vault can call this. function doHardWork() external; /// @notice Emergency stop investing by strategy, withdraw liquidity without rewards. /// This action triggers FUSE mode. /// Only governance or multisig can call this. function emergencyStopInvesting() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; /// @title ZAP feature interface IZap { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ error StrategyNotSupported(); error NotAllowedDexAggregator(address dexAggRouter); error AggSwapFailed(string reason); error Slippage(uint amountOut, uint minAmountOut); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* VIEW */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @notice Request for swap amounts required to execute ZAP deposit /// @param vault Address of vault to invest /// @param tokenIn Input token address /// @param amountIn Amount of input token /// @return tokensOut Strategy assets /// @return swapAmounts Amounts for swap tokenIn -> asset function getDepositSwapAmounts( address vault, address tokenIn, uint amountIn ) external view returns (address[] memory tokensOut, uint[] memory swapAmounts); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* WRITE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @notice Allows to deposit into vault with swap tokenIn to vault assets /// @param vault Address of vault to invest /// @param tokenIn Input token address /// @param amountIn Amount of input token /// @param agg Address of aggregator /// @param swapData Swap data from 1inch API /// @param minSharesOut Minimum expected shares to be minted for user /// @param receiver Receiver of minted shares function deposit( address vault, address tokenIn, uint amountIn, address agg, bytes[] memory swapData, uint minSharesOut, address receiver ) external; /// @notice Allows to withdraw assets from vault with swap to exact tokenOut /// @param vault Address of vault to withdraw /// @param tokenOut Output token address /// @param agg Address of aggregator /// @param swapData Swap data from 1inch API /// @param sharesToBurn Shares to be burn (exchage) for assets /// @param minAmountOut Minimum expected amount of tokenOut to be received function withdraw( address vault, address tokenOut, address agg, bytes[] memory swapData, uint sharesToBurn, uint minAmountOut ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @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. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ 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]. * * CAUTION: See Security Considerations above. */ 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 (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @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] * ```solidity * 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 Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._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() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; /// @title Minimal library for setting / getting slot variables (used in upgradable proxy contracts) library SlotsLib { /// @dev Gets a slot as an address function getAddress(bytes32 slot) internal view returns (address result) { assembly { result := sload(slot) } } /// @dev Gets a slot as uint256 function getUint(bytes32 slot) internal view returns (uint result) { assembly { result := sload(slot) } } /// @dev Sets a slot with address /// @notice Check address for 0 at the setter function set(bytes32 slot, address value) internal { assembly { sstore(slot, value) } } /// @dev Sets a slot with uint function set(bytes32 slot, uint value) internal { assembly { sstore(slot, value) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; /// @dev Base core interface implemented by most platform contracts. /// Inherited contracts store an immutable Platform proxy address in the storage, /// which provides authorization capabilities and infrastructure contract addresses. /// @author Alien Deployer (https://github.com/a17) /// @author JodsMigel (https://github.com/JodsMigel) interface IControllable { //region ----- Custom Errors ----- error IncorrectZeroArgument(); error IncorrectMsgSender(); error NotGovernance(); error NotMultisig(); error NotGovernanceAndNotMultisig(); error NotOperator(); error NotFactory(); error NotPlatform(); error NotVault(); error IncorrectArrayLength(); error AlreadyExist(); error NotExist(); error NotTheOwner(); error ETHTransferFailed(); error IncorrectInitParams(); //endregion -- Custom Errors ----- event ContractInitialized(address platform, uint ts, uint block); /// @notice Stability Platform main contract address function platform() external view returns (address); /// @notice Version of contract implementation /// @dev SemVer scheme MAJOR.MINOR.PATCH //slither-disable-next-line naming-convention function VERSION() external view returns (string memory); /// @notice Block number when contract was initialized function createdBlock() external view returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; /// @notice Interface of the main contract and entry point to the platform. /// @author Alien Deployer (https://github.com/a17) /// @author Jude (https://github.com/iammrjude) /// @author JodsMigel (https://github.com/JodsMigel) interface IPlatform { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ error AlreadyAnnounced(); error SameVersion(); error NoNewVersion(); error UpgradeTimerIsNotOver(uint TimerTimestamp); error IncorrectFee(uint minFee, uint maxFee); error NotEnoughAllowedBBToken(); error TokenAlreadyExistsInSet(address token); error AggregatorNotExists(address dexAggRouter); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ event PlatformVersion(string version); event UpgradeAnnounce( string oldVersion, string newVersion, address[] proxies, address[] newImplementations, uint timelock ); event CancelUpgrade(string oldVersion, string newVersion); event ProxyUpgraded( address indexed proxy, address implementation, string oldContractVersion, string newContractVersion ); event Addresses( address multisig_, address factory_, address priceReader_, address swapper_, address buildingPermitToken_, address vaultManager_, address strategyLogic_, address aprOracle_, address hardWorker, address rebalancer, address zap, address bridge ); event OperatorAdded(address operator); event OperatorRemoved(address operator); event FeesChanged(uint fee, uint feeShareVaultManager, uint feeShareStrategyLogic, uint feeShareEcosystem); event MinInitialBoostChanged(uint minInitialBoostPerDay, uint minInitialBoostDuration); event NewAmmAdapter(string id, address proxy); event EcosystemRevenueReceiver(address receiver); event SetAllowedBBTokenVaults(address bbToken, uint vaultsToBuild, bool firstSet); event RemoveAllowedBBToken(address bbToken); event AddAllowedBoostRewardToken(address token); event RemoveAllowedBoostRewardToken(address token); event AddDefaultBoostRewardToken(address token); event RemoveDefaultBoostRewardToken(address token); event AddBoostTokens(address[] allowedBoostRewardToken, address[] defaultBoostRewardToken); event AllowedBBTokenVaultUsed(address bbToken, uint vaultToUse); event AddDexAggregator(address router); event RemoveDexAggregator(address router); event MinTvlForFreeHardWorkChanged(uint oldValue, uint newValue); event CustomVaultFee(address vault, uint platformFee); event Rebalancer(address rebalancer_); event Bridge(address bridge_); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* DATA TYPES */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ struct PlatformUpgrade { string newVersion; address[] proxies; address[] newImplementations; } struct PlatformSettings { string networkName; bytes32 networkExtra; uint fee; uint feeShareVaultManager; uint feeShareStrategyLogic; uint feeShareEcosystem; uint minInitialBoostPerDay; uint minInitialBoostDuration; } struct AmmAdapter { string id; address proxy; } struct SetupAddresses { address factory; address priceReader; address swapper; address buildingPermitToken; address buildingPayPerVaultToken; address vaultManager; address strategyLogic; address aprOracle; address targetExchangeAsset; address hardWorker; address zap; address bridge; address rebalancer; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* VIEW FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @notice Platform version in CalVer scheme: YY.MM.MINOR-tag. Updates on core contract upgrades. function platformVersion() external view returns (string memory); /// @notice Time delay for proxy upgrades of core contracts and changing important platform settings by multisig //slither-disable-next-line naming-convention function TIME_LOCK() external view returns (uint); /// @notice DAO governance function governance() external view returns (address); /// @notice Core team multi signature wallet. Development and operations fund function multisig() external view returns (address); /// @notice This NFT allow user to build limited number of vaults per week function buildingPermitToken() external view returns (address); /// @notice This ERC20 token is used as payment token for vault building function buildingPayPerVaultToken() external view returns (address); /// @notice Receiver of ecosystem revenue function ecosystemRevenueReceiver() external view returns (address); /// @dev The best asset in a network for swaps between strategy assets and farms rewards assets /// The target exchange asset is used for finding the best strategy's exchange asset. /// Rhe fewer routes needed to swap to the target exchange asset, the better. function targetExchangeAsset() external view returns (address); /// @notice Platform factory assembling vaults. Stores settings, strategy logic, farms. /// Provides the opportunity to upgrade vaults and strategies. /// @return Address of Factory proxy function factory() external view returns (address); /// @notice The holders of these NFT receive a share of the vault revenue /// @return Address of VaultManager proxy function vaultManager() external view returns (address); /// @notice The holders of these tokens receive a share of the revenue received in all vaults using this strategy logic. function strategyLogic() external view returns (address); /// @notice Combining oracle and DeX spot prices /// @return Address of PriceReader proxy function priceReader() external view returns (address); /// @notice Providing underlying assets APRs on-chain /// @return Address of AprOracle proxy function aprOracle() external view returns (address); /// @notice On-chain price quoter and swapper /// @return Address of Swapper proxy function swapper() external view returns (address); /// @notice HardWork resolver and caller /// @return Address of HardWorker proxy function hardWorker() external view returns (address); /// @notice Rebalance resolver /// @return Address of Rebalancer proxy function rebalancer() external view returns (address); /// @notice ZAP feature /// @return Address of Zap proxy function zap() external view returns (address); /// @notice Stability Bridge /// @return Address of Bridge proxy function bridge() external view returns (address); /// @notice Name of current EVM network function networkName() external view returns (string memory); /// @notice Minimal initial boost rewards per day USD amount which needs to create rewarding vault function minInitialBoostPerDay() external view returns (uint); /// @notice Minimal boost rewards vesting duration for initial boost function minInitialBoostDuration() external view returns (uint); /// @notice This function provides the timestamp of the platform upgrade timelock. /// @dev This function is an external view function, meaning it doesn't modify the state. /// @return uint representing the timestamp of the platform upgrade timelock. function platformUpgradeTimelock() external view returns (uint); /// @dev Extra network data /// @return 0-2 bytes - color /// 3-5 bytes - background color /// 6-31 bytes - free function networkExtra() external view returns (bytes32); /// @notice Pending platform upgrade data function pendingPlatformUpgrade() external view returns (PlatformUpgrade memory); /// @notice Get platform revenue fee settings /// @return fee Revenue fee % (between MIN_FEE - MAX_FEE) with DENOMINATOR precision. /// @return feeShareVaultManager Revenue fee share % of VaultManager tokenId owner /// @return feeShareStrategyLogic Revenue fee share % of StrategyLogic tokenId owner /// @return feeShareEcosystem Revenue fee share % of ecosystemFeeReceiver function getFees() external view returns (uint fee, uint feeShareVaultManager, uint feeShareStrategyLogic, uint feeShareEcosystem); /// @notice Get custom vault platform fee /// @return fee revenue fee % with DENOMINATOR precision function getCustomVaultFee(address vault) external view returns (uint fee); /// @notice Platform settings function getPlatformSettings() external view returns (PlatformSettings memory); /// @notice AMM adapters of the platform function getAmmAdapters() external view returns (string[] memory id, address[] memory proxy); /// @notice Get AMM adapter data by hash /// @param ammAdapterIdHash Keccak256 hash of adapter ID string /// @return ID string and proxy address of AMM adapter function ammAdapter(bytes32 ammAdapterIdHash) external view returns (AmmAdapter memory); /// @notice Allowed buy-back tokens for rewarding vaults function allowedBBTokens() external view returns (address[] memory); /// @notice Vaults building limit for buy-back token. /// This limit decrements when a vault for BB-token is built. /// @param token Allowed buy-back token /// @return vaultsLimit Number of vaults that can be built for BB-token function allowedBBTokenVaults(address token) external view returns (uint vaultsLimit); /// @notice Vaults building limits for allowed buy-back tokens. /// @return bbToken Allowed buy-back tokens /// @return vaultsLimit Number of vaults that can be built for BB-tokens function allowedBBTokenVaults() external view returns (address[] memory bbToken, uint[] memory vaultsLimit); /// @notice Non-zero vaults building limits for allowed buy-back tokens. /// @return bbToken Allowed buy-back tokens /// @return vaultsLimit Number of vaults that can be built for BB-tokens function allowedBBTokenVaultsFiltered() external view returns (address[] memory bbToken, uint[] memory vaultsLimit); /// @notice Check address for existance in operators list /// @param operator Address /// @return True if this address is Stability Operator function isOperator(address operator) external view returns (bool); /// @notice Tokens that can be used for boost rewards of rewarding vaults /// @return Addresses of tokens function allowedBoostRewardTokens() external view returns (address[] memory); /// @notice Allowed boost reward tokens that used for unmanaged rewarding vaults creation /// @return Addresses of tokens function defaultBoostRewardTokens() external view returns (address[] memory); /// @notice Allowed boost reward tokens that used for unmanaged rewarding vaults creation /// @param addressToRemove This address will be removed from default boost reward tokens /// @return Addresses of tokens function defaultBoostRewardTokensFiltered(address addressToRemove) external view returns (address[] memory); /// @notice Allowed DeX aggregators /// @return Addresses of DeX aggregator rounters function dexAggregators() external view returns (address[] memory); /// @notice DeX aggregator router address is allowed to be used in the platform /// @param dexAggRouter Address of DeX aggreagator router /// @return Can be used function isAllowedDexAggregatorRouter(address dexAggRouter) external view returns (bool); /// @notice Show minimum TVL for compensate if vault has not enough ETH /// @return Minimum TVL for compensate. function minTvlForFreeHardWork() external view returns (uint); /// @notice Front-end platform viewer /// @return platformAddresses Platform core addresses /// platformAddresses[0] factory /// platformAddresses[1] vaultManager /// platformAddresses[2] strategyLogic /// platformAddresses[3] buildingPermitToken /// platformAddresses[4] buildingPayPerVaultToken /// platformAddresses[5] governance /// platformAddresses[6] multisig /// platformAddresses[7] zap /// platformAddresses[8] bridge /// @return bcAssets Blue chip token addresses /// @return dexAggregators_ DeX aggregators allowed to be used entire the platform /// @return vaultType Vault type ID strings /// @return vaultExtra Vault color, background color and other extra data. Index of vault same as in previous array. /// @return vaultBulldingPrice Price of creating new vault in buildingPayPerVaultToken. Index of vault same as in previous array. /// @return strategyId Strategy logic ID strings /// @return isFarmingStrategy True if strategy is farming strategy. Index of strategy same as in previous array. /// @return strategyTokenURI StrategyLogic NFT tokenId metadata and on-chain image. Index of strategy same as in previous array. /// @return strategyExtra Strategy color, background color and other extra data. Index of strategy same as in previous array. function getData() external view returns ( address[] memory platformAddresses, address[] memory bcAssets, address[] memory dexAggregators_, string[] memory vaultType, bytes32[] memory vaultExtra, uint[] memory vaultBulldingPrice, string[] memory strategyId, bool[] memory isFarmingStrategy, string[] memory strategyTokenURI, bytes32[] memory strategyExtra ); // todo add vaultSymbol, vaultName /// @notice Front-end balances, prices and vault list viewer /// @param yourAccount Address of account to query balances /// @return token Tokens supported by the platform /// @return tokenPrice USD price of token. Index of token same as in previous array. /// @return tokenUserBalance User balance of token. Index of token same as in previous array. /// @return vault Deployed vaults /// @return vaultSharePrice Price 1.0 vault share. Index of vault same as in previous array. /// @return vaultUserBalance User balance of vault. Index of vault same as in previous array. /// @return nft Ecosystem NFTs /// nft[0] BuildingPermitToken /// nft[1] VaultManager /// nft[2] StrategyLogic /// @return nftUserBalance User balance of NFT. Index of NFT same as in previous array. /// @return buildingPayPerVaultTokenBalance User balance of vault creation paying token function getBalance(address yourAccount) external view returns ( address[] memory token, uint[] memory tokenPrice, uint[] memory tokenUserBalance, address[] memory vault, uint[] memory vaultSharePrice, uint[] memory vaultUserBalance, address[] memory nft, uint[] memory nftUserBalance, uint buildingPayPerVaultTokenBalance ); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* WRITE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @notice Add platform operator. /// Only governance and multisig can add operator. /// @param operator Address of new operator function addOperator(address operator) external; /// @notice Remove platform operator. /// Only governance and multisig can remove operator. /// @param operator Address of operator to remove function removeOperator(address operator) external; /// @notice Announce upgrade of platform proxies implementations /// Only governance and multisig can announce platform upgrades. /// @param newVersion New platform version. Version must be changed when upgrading. /// @param proxies Addresses of core contract proxies /// @param newImplementations New implementation for proxy. Index of proxy same as in previous array. function announcePlatformUpgrade( string memory newVersion, address[] memory proxies, address[] memory newImplementations ) external; /// @notice Upgrade platform /// Only operator (multisig is operator too) can ececute pending platform upgrade function upgrade() external; /// @notice Cancel pending platform upgrade /// Only operator (multisig is operator too) can ececute pending platform upgrade function cancelUpgrade() external; /// @notice Register AMM adapter in platform /// @param id AMM adapter ID string from AmmAdapterIdLib /// @param proxy Address of AMM adapter proxy function addAmmAdapter(string memory id, address proxy) external; // todo Only governance and multisig can set allowed bb-token vaults building limit /// @notice Set new vaults building limit for buy-back token /// @param bbToken Address of allowed buy-back token /// @param vaultsToBuild Number of vaults that can be built for BB-token function setAllowedBBTokenVaults(address bbToken, uint vaultsToBuild) external; // todo Only governance and multisig can add allowed boost reward token /// @notice Add new allowed boost reward token /// @param token Address of token function addAllowedBoostRewardToken(address token) external; // todo Only governance and multisig can remove allowed boost reward token /// @notice Remove allowed boost reward token /// @param token Address of allowed boost reward token function removeAllowedBoostRewardToken(address token) external; // todo Only governance and multisig can add default boost reward token /// @notice Add default boost reward token /// @param token Address of default boost reward token function addDefaultBoostRewardToken(address token) external; // todo Only governance and multisig can remove default boost reward token /// @notice Remove default boost reward token /// @param token Address of allowed boost reward token function removeDefaultBoostRewardToken(address token) external; // todo Only governance and multisig can add allowed boost reward token // todo Only governance and multisig can add default boost reward token /// @notice Add new allowed boost reward token /// @notice Add default boost reward token /// @param allowedBoostRewardToken Address of allowed boost reward token /// @param defaultBoostRewardToken Address of default boost reward token function addBoostTokens( address[] memory allowedBoostRewardToken, address[] memory defaultBoostRewardToken ) external; /// @notice Decrease allowed BB-token vault building limit when vault is built /// Only Factory can do it. /// @param bbToken Address of allowed buy-back token function useAllowedBBTokenVault(address bbToken) external; /// @notice Allow DeX aggregator routers to be used in the platform /// @param dexAggRouter Addresses of DeX aggreagator routers function addDexAggregators(address[] memory dexAggRouter) external; /// @notice Remove allowed DeX aggregator router from the platform /// @param dexAggRouter Address of DeX aggreagator router function removeDexAggregator(address dexAggRouter) external; /// @notice Change initial boost rewards settings /// @param minInitialBoostPerDay_ Minimal initial boost rewards per day USD amount which needs to create rewarding vault /// @param minInitialBoostDuration_ Minimal boost rewards vesting duration for initial boost function setInitialBoost(uint minInitialBoostPerDay_, uint minInitialBoostDuration_) external; /// @notice Update new minimum TVL for compensate. /// @param value New minimum TVL for compensate. function setMinTvlForFreeHardWork(uint value) external; /// @notice Set custom platform fee for vault /// @param vault Vault address /// @param platformFee Custom platform fee function setCustomVaultFee(address vault, uint platformFee) external; /// @notice Setup Rebalancer. /// Only Goverannce or Multisig can do this when Rebalancer is not set. /// @param rebalancer_ Proxy address of Bridge function setupRebalancer(address rebalancer_) external; /// @notice Setup Bridge. /// Only Goverannce or Multisig can do this when Bridge is not set. /// @param bridge_ Proxy address of Bridge function setupBridge(address bridge_) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@solady/=lib/solady/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/", "solady/=lib/solady/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "shanghai", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"AggSwapFailed","type":"error"},{"inputs":[],"name":"AlreadyExist","type":"error"},{"inputs":[],"name":"ETHTransferFailed","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"IncorrectArrayLength","type":"error"},{"inputs":[],"name":"IncorrectInitParams","type":"error"},{"inputs":[],"name":"IncorrectMsgSender","type":"error"},{"inputs":[],"name":"IncorrectZeroArgument","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"address","name":"dexAggRouter","type":"address"}],"name":"NotAllowedDexAggregator","type":"error"},{"inputs":[],"name":"NotExist","type":"error"},{"inputs":[],"name":"NotFactory","type":"error"},{"inputs":[],"name":"NotGovernance","type":"error"},{"inputs":[],"name":"NotGovernanceAndNotMultisig","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotMultisig","type":"error"},{"inputs":[],"name":"NotOperator","type":"error"},{"inputs":[],"name":"NotPlatform","type":"error"},{"inputs":[],"name":"NotTheOwner","type":"error"},{"inputs":[],"name":"NotVault","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"Slippage","type":"error"},{"inputs":[],"name":"StrategyNotSupported","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"platform","type":"address"},{"indexed":false,"internalType":"uint256","name":"ts","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"block","type":"uint256"}],"name":"ContractInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"inputs":[],"name":"CONTROLLABLE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"createdBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"agg","type":"address"},{"internalType":"bytes[]","name":"swapData","type":"bytes[]"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getDepositSwapAmounts","outputs":[{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"uint256[]","name":"swapAmounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"platform_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"platform","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"address","name":"agg","type":"address"},{"internalType":"bytes[]","name":"swapData","type":"bytes[]"},{"internalType":"uint256","name":"sharesToBurn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561000f575f80fd5b5061001861001d565b6100cf565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006d5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cc5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b611cf0806100dc5f395ff3fe608060405234801561000f575f80fd5b5060043610610090575f3560e01c80635f9808cf116100635780635f9808cf14610107578063936725ec1461011a578063c4d66de81461014b578063ea44148b1461015e578063ffa1ad741461017f575f80fd5b806301ffc9a7146100945780630a3cce8e146100bc5780634593144c146100d15780634bde38c8146100e7575b5f80fd5b6100a76100a236600461161f565b6101a3565b60405190151581526020015b60405180910390f35b6100cf6100ca3660046117a2565b6101d9565b005b6100d96106c0565b6040519081526020016100b3565b6100ef6106f8565b6040516001600160a01b0390911681526020016100b3565b6100cf610115366004611839565b610727565b61013e604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516100b391906118dd565b6100cf61015936600461190f565b610b65565b61017161016c36600461192a565b610c7a565b6040516100b39291906119da565b61013e60405180604001604052806005815260200164312e302e3360d81b81525081565b5f6001600160e01b03198216630f1ec81f60e41b14806101d357506301ffc9a760e01b6001600160e01b03198316145b92915050565b6101e1610f42565b845f03610201576040516371c42ac360e01b815260040160405180910390fd5b6102096106f8565b604051626ccc0f60e51b81526001600160a01b0386811660048301529190911690630d9981e090602401602060405180830381865afa15801561024e573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061027291906119fe565b61029f57604051633db861fd60e01b81526001600160a01b03851660048201526024015b60405180910390fd5b6001600160a01b0381166102b05750335b6102c56001600160a01b038716333088610f79565b6102d0868686610fe6565b5f876001600160a01b031663a8c62e766040518163ffffffff1660e01b8152600401602060405180830381865afa15801561030d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103319190611a1d565b90505f816001600160a01b03166371a973056040518163ffffffff1660e01b81526004015f60405180830381865afa15801561036f573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526103969190810190611a38565b80519091505f8167ffffffffffffffff8111156103b5576103b561165a565b6040519080825280602002602001820160405280156103de578160200160208202803683370190505b5090505f5b828110156104e1578381815181106103fd576103fd611acd565b60200260200101516001600160a01b03168b6001600160a01b031603156104d95787818151811061043057610430611acd565b6020026020010151515f03156104d9575f808a6001600160a01b03168a848151811061045e5761045e611acd565b60200260200101516040516104739190611ae1565b5f604051808303815f865af19150503d805f81146104ac576040519150601f19603f3d011682016040523d82523d5f602084013e6104b1565b606091505b5091509150816104d6578060405163bcf6777760e01b815260040161029691906118dd565b50505b6001016103e3565b505f5b828110156105d3578381815181106104fe576104fe611acd565b60209081029190910101516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561054c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105709190611afc565b82828151811061058257610582611acd565b6020026020010181815250506105cb8482815181106105a3576105a3611acd565b60200260200101518383815181106105bd576105bd611acd565b60200260200101518e610fe6565b6001016104e4565b5060405163b256cd8b60e01b81526001600160a01b038c169063b256cd8b9061060690869085908b908b90600401611b13565b5f604051808303815f87803b15801561061d575f80fd5b505af115801561062f573d5f803e3d5ffd5b5050505061069d8a84866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610674573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106989190611a1d565b611077565b505050506106b760015f80516020611c9b83398151915255565b50505050505050565b5f6106f36106ef60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1611b6d565b5490565b905090565b5f6106f36106ef60017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d6611b6d565b61072f610f42565b6107376106f8565b604051626ccc0f60e51b81526001600160a01b0386811660048301529190911690630d9981e090602401602060405180830381865afa15801561077c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107a091906119fe565b6107c857604051633db861fd60e01b81526001600160a01b0385166004820152602401610296565b5f835190505f876001600160a01b031663a8c62e766040518163ffffffff1660e01b8152600401602060405180830381865afa15801561080a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061082e9190611a1d565b90505f816001600160a01b03166371a973056040518163ffffffff1660e01b81526004015f60405180830381865afa15801561086c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526108939190810190611a38565b90505f896001600160a01b0316632cbfd6a383888767ffffffffffffffff8111156108c0576108c061165a565b6040519080825280602002602001820160405280156108e9578160200160208202803683370190505b5030336040518663ffffffff1660e01b815260040161090c959493929190611b80565b5f604051808303815f875af1158015610927573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261094e9190810190611bd0565b90505f5b84811015610a6b5782818151811061096c5761096c611acd565b60200260200101516001600160a01b03168a6001600160a01b03160315610a63576109ca8382815181106109a2576109a2611acd565b60200260200101518383815181106109bc576109bc611acd565b60200260200101518b610fe6565b5f808a6001600160a01b03168a84815181106109e8576109e8611acd565b60200260200101516040516109fd9190611ae1565b5f604051808303815f865af19150503d805f8114610a36576040519150601f19603f3d011682016040523d82523d5f602084013e610a3b565b606091505b509150915081610a60578060405163bcf6777760e01b815260040161029691906118dd565b50505b600101610952565b506040516370a0823160e01b81523060048201525f906001600160a01b038b16906370a0823190602401602060405180830381865afa158015610ab0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ad49190611afc565b905085811015610b01576040516313a30a9560e11b81526004810182905260248101879052604401610296565b610b428a84866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610674573d5f803e3d5ffd5b5050505050610b5d60015f80516020611c9b83398151915255565b505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610baa5750825b90505f8267ffffffffffffffff166001148015610bc65750303b155b905081158015610bd4575080155b15610bf25760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c1c57845460ff60401b1916600160401b1785555b610c25866110e2565b610c2d61123d565b8315610b5d57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a1505050505050565b6060805f856001600160a01b031663a8c62e766040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cba573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cde9190611a1d565b9050806001600160a01b03166371a973056040518163ffffffff1660e01b81526004015f60405180830381865afa158015610d1b573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610d429190810190611a38565b80519093508067ffffffffffffffff811115610d6057610d6061165a565b604051908082528060200260200182016040528015610d89578160200160208202803683370190505b5092505f826001600160a01b03166367cf905a6040518163ffffffff1660e01b81526004015f60405180830381865afa158015610dc8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610def9190810190611bd0565b90505f805b83811015610f3557886001600160a01b0316878281518110610e1857610e18611acd565b60200260200101516001600160a01b031603610e7757670de0b6b3a7640000838281518110610e4957610e49611acd565b602002602001015189610e5c9190611c51565b610e669190611c68565b610e709083611c87565b9150610f2d565b610e82600185611b6d565b811015610f0457670de0b6b3a7640000838281518110610ea457610ea4611acd565b602002602001015189610eb79190611c51565b610ec19190611c68565b868281518110610ed357610ed3611acd565b602002602001018181525050858181518110610ef157610ef1611acd565b602002602001015182610e709190611c87565b610f0e8289611b6d565b868281518110610f2057610f20611acd565b6020026020010181815250505b600101610df4565b5050505050935093915050565b5f80516020611c9b833981519152805460011901610f7357604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6040516001600160a01b038481166024830152838116604483015260648201839052610fe09186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061124f565b50505050565b604051636eb1769f60e11b81523060048201526001600160a01b03828116602483015283919085169063dd62ed3e90604401602060405180830381865afa158015611033573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110579190611afc565b1015611072576110726001600160a01b038416825f196112b0565b505050565b6110808361133f565b81515f5b818110156110b6576110ae8482815181106110a1576110a1611acd565b602002602001015161133f565b600101611084565b506001600160a01b03821615610fe057610fe08261133f565b60015f80516020611c9b83398151915255565b6110ea6113c7565b6001600160a01b038116158061117057505f6001600160a01b0316816001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611141573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111659190611a1d565b6001600160a01b0316145b1561118e576040516371c42ac360e01b815260040160405180910390fd5b6111c16111bc60017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d6611b6d565b829055565b6111f3436111f060017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1611b6d565b55565b604080516001600160a01b0383168152426020820152438183015290517f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe2367134269181900360600190a150565b6112456113c7565b61124d611410565b565b5f6112636001600160a01b03841683611418565b905080515f1415801561128757508080602001905181019061128591906119fe565b155b1561107257604051635274afe760e01b81526001600160a01b0384166004820152602401610296565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611301848261142c565b610fe0576040516001600160a01b0384811660248301525f604483015261133591869182169063095ea7b390606401610fae565b610fe0848261124f565b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa158015611383573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113a79190611afc565b905080156113c3576113c36001600160a01b03831633836114cd565b5050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661124d57604051631afcd79f60e31b815260040160405180910390fd5b6110cf6113c7565b606061142583835f6114fe565b9392505050565b5f805f846001600160a01b0316846040516114479190611ae1565b5f604051808303815f865af19150503d805f8114611480576040519150601f19603f3d011682016040523d82523d5f602084013e611485565b606091505b50915091508180156114af5750805115806114af5750808060200190518101906114af91906119fe565b80156114c457505f856001600160a01b03163b115b95945050505050565b6040516001600160a01b0383811660248301526044820183905261107291859182169063a9059cbb90606401610fae565b6060814710156115235760405163cd78605960e01b8152306004820152602401610296565b5f80856001600160a01b0316848660405161153e9190611ae1565b5f6040518083038185875af1925050503d805f8114611578576040519150601f19603f3d011682016040523d82523d5f602084013e61157d565b606091505b509150915061158d868383611597565b9695505050505050565b6060826115ac576115a7826115f3565b611425565b81511580156115c357506001600160a01b0384163b155b156115ec57604051639996b31560e01b81526001600160a01b0385166004820152602401610296565b5080611425565b8051156116035780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b5f6020828403121561162f575f80fd5b81356001600160e01b031981168114611425575f80fd5b6001600160a01b038116811461161c575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156116975761169761165a565b604052919050565b5f67ffffffffffffffff8211156116b8576116b861165a565b5060051b60200190565b5f601f83601f8401126116d3575f80fd5b823560206116e86116e38361169f565b61166e565b82815260059290921b85018101918181019087841115611706575f80fd5b8287015b8481101561179657803567ffffffffffffffff80821115611729575f80fd5b818a0191508a603f83011261173c575f80fd5b858201356040828211156117525761175261165a565b611763828b01601f1916890161166e565b92508183528c81838601011115611778575f80fd5b8181850189850137505f90820187015284525091830191830161170a565b50979650505050505050565b5f805f805f805f60e0888a0312156117b8575f80fd5b87356117c381611646565b965060208801356117d381611646565b95506040880135945060608801356117ea81611646565b9350608088013567ffffffffffffffff811115611805575f80fd5b6118118a828b016116c2565b93505060a0880135915060c088013561182981611646565b8091505092959891949750929550565b5f805f805f8060c0878903121561184e575f80fd5b863561185981611646565b9550602087013561186981611646565b9450604087013561187981611646565b9350606087013567ffffffffffffffff811115611894575f80fd5b6118a089828a016116c2565b9350506080870135915060a087013590509295509295509295565b5f5b838110156118d55781810151838201526020016118bd565b50505f910152565b602081525f82518060208401526118fb8160408501602087016118bb565b601f01601f19169190910160400192915050565b5f6020828403121561191f575f80fd5b813561142581611646565b5f805f6060848603121561193c575f80fd5b833561194781611646565b9250602084013561195781611646565b929592945050506040919091013590565b5f815180845260208085019450602084015f5b838110156119a05781516001600160a01b03168752958201959082019060010161197b565b509495945050505050565b5f815180845260208085019450602084015f5b838110156119a0578151875295820195908201906001016119be565b604081525f6119ec6040830185611968565b82810360208401526114c481856119ab565b5f60208284031215611a0e575f80fd5b81518015158114611425575f80fd5b5f60208284031215611a2d575f80fd5b815161142581611646565b5f6020808385031215611a49575f80fd5b825167ffffffffffffffff811115611a5f575f80fd5b8301601f81018513611a6f575f80fd5b8051611a7d6116e38261169f565b81815260059190911b82018301908381019087831115611a9b575f80fd5b928401925b82841015611ac2578351611ab381611646565b82529284019290840190611aa0565b979650505050505050565b634e487b7160e01b5f52603260045260245ffd5b5f8251611af28184602087016118bb565b9190910192915050565b5f60208284031215611b0c575f80fd5b5051919050565b608081525f611b256080830187611968565b8281036020840152611b3781876119ab565b604084019590955250506001600160a01b039190911660609091015292915050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156101d3576101d3611b59565b60a081525f611b9260a0830188611968565b8660208401528281036040840152611baa81876119ab565b6001600160a01b0395861660608501529390941660809092019190915250949350505050565b5f6020808385031215611be1575f80fd5b825167ffffffffffffffff811115611bf7575f80fd5b8301601f81018513611c07575f80fd5b8051611c156116e38261169f565b81815260059190911b82018301908381019087831115611c33575f80fd5b928401925b82841015611ac257835182529284019290840190611c38565b80820281158282048414176101d3576101d3611b59565b5f82611c8257634e487b7160e01b5f52601260045260245ffd5b500490565b808201808211156101d3576101d3611b5956fe9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a264697066735822122084f49d11a73e8b9d748af40c5de6d4b09c7fed4bbf57e0fd5a2529c42f9bb12364736f6c63430008170033
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610090575f3560e01c80635f9808cf116100635780635f9808cf14610107578063936725ec1461011a578063c4d66de81461014b578063ea44148b1461015e578063ffa1ad741461017f575f80fd5b806301ffc9a7146100945780630a3cce8e146100bc5780634593144c146100d15780634bde38c8146100e7575b5f80fd5b6100a76100a236600461161f565b6101a3565b60405190151581526020015b60405180910390f35b6100cf6100ca3660046117a2565b6101d9565b005b6100d96106c0565b6040519081526020016100b3565b6100ef6106f8565b6040516001600160a01b0390911681526020016100b3565b6100cf610115366004611839565b610727565b61013e604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516100b391906118dd565b6100cf61015936600461190f565b610b65565b61017161016c36600461192a565b610c7a565b6040516100b39291906119da565b61013e60405180604001604052806005815260200164312e302e3360d81b81525081565b5f6001600160e01b03198216630f1ec81f60e41b14806101d357506301ffc9a760e01b6001600160e01b03198316145b92915050565b6101e1610f42565b845f03610201576040516371c42ac360e01b815260040160405180910390fd5b6102096106f8565b604051626ccc0f60e51b81526001600160a01b0386811660048301529190911690630d9981e090602401602060405180830381865afa15801561024e573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061027291906119fe565b61029f57604051633db861fd60e01b81526001600160a01b03851660048201526024015b60405180910390fd5b6001600160a01b0381166102b05750335b6102c56001600160a01b038716333088610f79565b6102d0868686610fe6565b5f876001600160a01b031663a8c62e766040518163ffffffff1660e01b8152600401602060405180830381865afa15801561030d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103319190611a1d565b90505f816001600160a01b03166371a973056040518163ffffffff1660e01b81526004015f60405180830381865afa15801561036f573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526103969190810190611a38565b80519091505f8167ffffffffffffffff8111156103b5576103b561165a565b6040519080825280602002602001820160405280156103de578160200160208202803683370190505b5090505f5b828110156104e1578381815181106103fd576103fd611acd565b60200260200101516001600160a01b03168b6001600160a01b031603156104d95787818151811061043057610430611acd565b6020026020010151515f03156104d9575f808a6001600160a01b03168a848151811061045e5761045e611acd565b60200260200101516040516104739190611ae1565b5f604051808303815f865af19150503d805f81146104ac576040519150601f19603f3d011682016040523d82523d5f602084013e6104b1565b606091505b5091509150816104d6578060405163bcf6777760e01b815260040161029691906118dd565b50505b6001016103e3565b505f5b828110156105d3578381815181106104fe576104fe611acd565b60209081029190910101516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561054c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105709190611afc565b82828151811061058257610582611acd565b6020026020010181815250506105cb8482815181106105a3576105a3611acd565b60200260200101518383815181106105bd576105bd611acd565b60200260200101518e610fe6565b6001016104e4565b5060405163b256cd8b60e01b81526001600160a01b038c169063b256cd8b9061060690869085908b908b90600401611b13565b5f604051808303815f87803b15801561061d575f80fd5b505af115801561062f573d5f803e3d5ffd5b5050505061069d8a84866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610674573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106989190611a1d565b611077565b505050506106b760015f80516020611c9b83398151915255565b50505050505050565b5f6106f36106ef60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1611b6d565b5490565b905090565b5f6106f36106ef60017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d6611b6d565b61072f610f42565b6107376106f8565b604051626ccc0f60e51b81526001600160a01b0386811660048301529190911690630d9981e090602401602060405180830381865afa15801561077c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107a091906119fe565b6107c857604051633db861fd60e01b81526001600160a01b0385166004820152602401610296565b5f835190505f876001600160a01b031663a8c62e766040518163ffffffff1660e01b8152600401602060405180830381865afa15801561080a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061082e9190611a1d565b90505f816001600160a01b03166371a973056040518163ffffffff1660e01b81526004015f60405180830381865afa15801561086c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526108939190810190611a38565b90505f896001600160a01b0316632cbfd6a383888767ffffffffffffffff8111156108c0576108c061165a565b6040519080825280602002602001820160405280156108e9578160200160208202803683370190505b5030336040518663ffffffff1660e01b815260040161090c959493929190611b80565b5f604051808303815f875af1158015610927573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261094e9190810190611bd0565b90505f5b84811015610a6b5782818151811061096c5761096c611acd565b60200260200101516001600160a01b03168a6001600160a01b03160315610a63576109ca8382815181106109a2576109a2611acd565b60200260200101518383815181106109bc576109bc611acd565b60200260200101518b610fe6565b5f808a6001600160a01b03168a84815181106109e8576109e8611acd565b60200260200101516040516109fd9190611ae1565b5f604051808303815f865af19150503d805f8114610a36576040519150601f19603f3d011682016040523d82523d5f602084013e610a3b565b606091505b509150915081610a60578060405163bcf6777760e01b815260040161029691906118dd565b50505b600101610952565b506040516370a0823160e01b81523060048201525f906001600160a01b038b16906370a0823190602401602060405180830381865afa158015610ab0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ad49190611afc565b905085811015610b01576040516313a30a9560e11b81526004810182905260248101879052604401610296565b610b428a84866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610674573d5f803e3d5ffd5b5050505050610b5d60015f80516020611c9b83398151915255565b505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610baa5750825b90505f8267ffffffffffffffff166001148015610bc65750303b155b905081158015610bd4575080155b15610bf25760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c1c57845460ff60401b1916600160401b1785555b610c25866110e2565b610c2d61123d565b8315610b5d57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a1505050505050565b6060805f856001600160a01b031663a8c62e766040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cba573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cde9190611a1d565b9050806001600160a01b03166371a973056040518163ffffffff1660e01b81526004015f60405180830381865afa158015610d1b573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610d429190810190611a38565b80519093508067ffffffffffffffff811115610d6057610d6061165a565b604051908082528060200260200182016040528015610d89578160200160208202803683370190505b5092505f826001600160a01b03166367cf905a6040518163ffffffff1660e01b81526004015f60405180830381865afa158015610dc8573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610def9190810190611bd0565b90505f805b83811015610f3557886001600160a01b0316878281518110610e1857610e18611acd565b60200260200101516001600160a01b031603610e7757670de0b6b3a7640000838281518110610e4957610e49611acd565b602002602001015189610e5c9190611c51565b610e669190611c68565b610e709083611c87565b9150610f2d565b610e82600185611b6d565b811015610f0457670de0b6b3a7640000838281518110610ea457610ea4611acd565b602002602001015189610eb79190611c51565b610ec19190611c68565b868281518110610ed357610ed3611acd565b602002602001018181525050858181518110610ef157610ef1611acd565b602002602001015182610e709190611c87565b610f0e8289611b6d565b868281518110610f2057610f20611acd565b6020026020010181815250505b600101610df4565b5050505050935093915050565b5f80516020611c9b833981519152805460011901610f7357604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6040516001600160a01b038481166024830152838116604483015260648201839052610fe09186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061124f565b50505050565b604051636eb1769f60e11b81523060048201526001600160a01b03828116602483015283919085169063dd62ed3e90604401602060405180830381865afa158015611033573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110579190611afc565b1015611072576110726001600160a01b038416825f196112b0565b505050565b6110808361133f565b81515f5b818110156110b6576110ae8482815181106110a1576110a1611acd565b602002602001015161133f565b600101611084565b506001600160a01b03821615610fe057610fe08261133f565b60015f80516020611c9b83398151915255565b6110ea6113c7565b6001600160a01b038116158061117057505f6001600160a01b0316816001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611141573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111659190611a1d565b6001600160a01b0316145b1561118e576040516371c42ac360e01b815260040160405180910390fd5b6111c16111bc60017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d6611b6d565b829055565b6111f3436111f060017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f1611b6d565b55565b604080516001600160a01b0383168152426020820152438183015290517f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe2367134269181900360600190a150565b6112456113c7565b61124d611410565b565b5f6112636001600160a01b03841683611418565b905080515f1415801561128757508080602001905181019061128591906119fe565b155b1561107257604051635274afe760e01b81526001600160a01b0384166004820152602401610296565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611301848261142c565b610fe0576040516001600160a01b0384811660248301525f604483015261133591869182169063095ea7b390606401610fae565b610fe0848261124f565b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa158015611383573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113a79190611afc565b905080156113c3576113c36001600160a01b03831633836114cd565b5050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661124d57604051631afcd79f60e31b815260040160405180910390fd5b6110cf6113c7565b606061142583835f6114fe565b9392505050565b5f805f846001600160a01b0316846040516114479190611ae1565b5f604051808303815f865af19150503d805f8114611480576040519150601f19603f3d011682016040523d82523d5f602084013e611485565b606091505b50915091508180156114af5750805115806114af5750808060200190518101906114af91906119fe565b80156114c457505f856001600160a01b03163b115b95945050505050565b6040516001600160a01b0383811660248301526044820183905261107291859182169063a9059cbb90606401610fae565b6060814710156115235760405163cd78605960e01b8152306004820152602401610296565b5f80856001600160a01b0316848660405161153e9190611ae1565b5f6040518083038185875af1925050503d805f8114611578576040519150601f19603f3d011682016040523d82523d5f602084013e61157d565b606091505b509150915061158d868383611597565b9695505050505050565b6060826115ac576115a7826115f3565b611425565b81511580156115c357506001600160a01b0384163b155b156115ec57604051639996b31560e01b81526001600160a01b0385166004820152602401610296565b5080611425565b8051156116035780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b5f6020828403121561162f575f80fd5b81356001600160e01b031981168114611425575f80fd5b6001600160a01b038116811461161c575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156116975761169761165a565b604052919050565b5f67ffffffffffffffff8211156116b8576116b861165a565b5060051b60200190565b5f601f83601f8401126116d3575f80fd5b823560206116e86116e38361169f565b61166e565b82815260059290921b85018101918181019087841115611706575f80fd5b8287015b8481101561179657803567ffffffffffffffff80821115611729575f80fd5b818a0191508a603f83011261173c575f80fd5b858201356040828211156117525761175261165a565b611763828b01601f1916890161166e565b92508183528c81838601011115611778575f80fd5b8181850189850137505f90820187015284525091830191830161170a565b50979650505050505050565b5f805f805f805f60e0888a0312156117b8575f80fd5b87356117c381611646565b965060208801356117d381611646565b95506040880135945060608801356117ea81611646565b9350608088013567ffffffffffffffff811115611805575f80fd5b6118118a828b016116c2565b93505060a0880135915060c088013561182981611646565b8091505092959891949750929550565b5f805f805f8060c0878903121561184e575f80fd5b863561185981611646565b9550602087013561186981611646565b9450604087013561187981611646565b9350606087013567ffffffffffffffff811115611894575f80fd5b6118a089828a016116c2565b9350506080870135915060a087013590509295509295509295565b5f5b838110156118d55781810151838201526020016118bd565b50505f910152565b602081525f82518060208401526118fb8160408501602087016118bb565b601f01601f19169190910160400192915050565b5f6020828403121561191f575f80fd5b813561142581611646565b5f805f6060848603121561193c575f80fd5b833561194781611646565b9250602084013561195781611646565b929592945050506040919091013590565b5f815180845260208085019450602084015f5b838110156119a05781516001600160a01b03168752958201959082019060010161197b565b509495945050505050565b5f815180845260208085019450602084015f5b838110156119a0578151875295820195908201906001016119be565b604081525f6119ec6040830185611968565b82810360208401526114c481856119ab565b5f60208284031215611a0e575f80fd5b81518015158114611425575f80fd5b5f60208284031215611a2d575f80fd5b815161142581611646565b5f6020808385031215611a49575f80fd5b825167ffffffffffffffff811115611a5f575f80fd5b8301601f81018513611a6f575f80fd5b8051611a7d6116e38261169f565b81815260059190911b82018301908381019087831115611a9b575f80fd5b928401925b82841015611ac2578351611ab381611646565b82529284019290840190611aa0565b979650505050505050565b634e487b7160e01b5f52603260045260245ffd5b5f8251611af28184602087016118bb565b9190910192915050565b5f60208284031215611b0c575f80fd5b5051919050565b608081525f611b256080830187611968565b8281036020840152611b3781876119ab565b604084019590955250506001600160a01b039190911660609091015292915050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156101d3576101d3611b59565b60a081525f611b9260a0830188611968565b8660208401528281036040840152611baa81876119ab565b6001600160a01b0395861660608501529390941660809092019190915250949350505050565b5f6020808385031215611be1575f80fd5b825167ffffffffffffffff811115611bf7575f80fd5b8301601f81018513611c07575f80fd5b8051611c156116e38261169f565b81815260059190911b82018301908381019087831115611c33575f80fd5b928401925b82841015611ac257835182529284019290840190611c38565b80820281158282048414176101d3576101d3611b59565b5f82611c8257634e487b7160e01b5f52601260045260245ffd5b500490565b808201808211156101d3576101d3611b5956fe9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a264697066735822122084f49d11a73e8b9d748af40c5de6d4b09c7fed4bbf57e0fd5a2529c42f9bb12364736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.