Polygon Sponsored slots available. Book your slot here!
Overview
POL Balance
POL Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
DecentOpenAction
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; import {LzBridgeData, TokenData, TokenPermitData} from "./lib/CoreStructs.sol"; import {IPublicationActionModule} from "./interfaces/IPublicationActionModule.sol"; import {IStargateRouter} from "./interfaces/stargate/IStargateRouter.sol"; import {CoreWrapper} from "./CoreWrapper.sol"; import {Types, InitializedAction} from "./lens/Types.sol"; import {HubRestricted} from "./lens/HubRestricted.sol"; import {IERC20} from "@openzeppelin-contracts/contracts/interfaces/IERC20.sol"; import {SafeERC20} from "@openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC165} from "@openzeppelin-contracts/contracts/utils/introspection/IERC165.sol"; import {LensModuleMetadata} from "./lens/LensModuleMetadata.sol"; contract DecentOpenAction is HubRestricted, IPublicationActionModule, LensModuleMetadata { address public coreWrapper; // profileId -> pubId -> initialize action mapping(uint256 => mapping(uint256 => InitializedAction)) public pubActions; constructor(address _coreWrapper, address _lensHubProxyContract, string memory _metadataURI) HubRestricted(_lensHubProxyContract) LensModuleMetadata(_metadataURI) { coreWrapper = _coreWrapper; } event ProcessedPublicationAction( uint256 publicationActedProfileId, uint256 publicationActedId, uint256 actorProfileId, address actorProfileOwner ); event InitializedPublicationAction(uint256 profileId, uint256 pubId, address transactionExecutor); error WrongBoxArgs(); function initializePublicationAction( uint256 profileId, uint256 pubId, address transactionExecutor, bytes calldata data ) external override returns (bytes memory) { (address targetContract, address paymentToken, uint256 chainId, uint256 cost, bytes memory signature) = abi.decode(data, (address, address, uint256, uint256, bytes)); pubActions[profileId][pubId] = InitializedAction({ targetContract: targetContract, paymentToken: paymentToken, signature: signature, cost: cost, chainId: chainId }); emit InitializedPublicationAction(profileId, pubId, transactionExecutor); return data; } function processPublicationAction(Types.ProcessActionParams calldata params) external override returns (bytes memory) { // ** execute box action ** // if (params.actionModuleData.length > 0) { executeBoxAction(params.actionModuleData, params.transactionExecutor, params.publicationActedProfileId, params.publicationActedId); } emit ProcessedPublicationAction( params.publicationActedProfileId, params.publicationActedId, params.actorProfileId, params.actorProfileOwner ); return params.actionModuleData; } function executeBoxAction(bytes calldata actionModuleData, address sender, uint256 profileId, uint256 pubId) internal { if (block.chainid != pubActions[profileId][pubId].chainId) { ( , TokenPermitData memory tokenPermitData, LzBridgeData memory lzBridgeData, TokenData memory tokenData, IStargateRouter.lzTxObj memory lzTxObj ) = abi.decode(actionModuleData, (uint8, TokenPermitData, LzBridgeData, TokenData, IStargateRouter.lzTxObj)); (, address target, address paymentToken,,,,) = abi.decode(tokenData.payload, (address, address, address, address, uint256, bytes, bytes)); _conditionalTransferAndIncreaseAllowance( tokenData.tokenIn, sender, tokenData.amountIn + tokenPermitData.feeERC20 ); _verifyArgs(paymentToken, target, profileId, pubId); CoreWrapper(payable(coreWrapper)).bridgeAndExecute(tokenPermitData, lzBridgeData, tokenData, lzTxObj); } else { ( , TokenPermitData memory tokenPermitData, address target, address paymentOperator, TokenData memory tokenData ) = abi.decode(actionModuleData, (uint8, TokenPermitData, address, address, TokenData)); _conditionalTransferAndIncreaseAllowance( tokenData.tokenIn, sender, tokenData.amountIn + tokenPermitData.feeERC20 ); _verifyArgs(tokenData.tokenOut, target, profileId, pubId); CoreWrapper(payable(coreWrapper)).swapAndExecute(tokenPermitData, target, paymentOperator, tokenData); } } function _conditionalTransferAndIncreaseAllowance(address token, address from, uint256 amount) private { if (token != address(0) && amount > 0) { SafeERC20.safeTransferFrom(IERC20(token), from, address(this), amount); SafeERC20.safeIncreaseAllowance(IERC20(token), coreWrapper, amount); } } function _verifyArgs(address tokenOut, address targetContract, uint256 profileId, uint256 pubId) private view { if (tokenOut != pubActions[profileId][pubId].paymentToken || targetContract != pubActions[profileId][pubId].targetContract) { revert WrongBoxArgs(); } } function supportsInterface(bytes4 interfaceID) public pure override returns (bool) { return interfaceID == type(IPublicationActionModule).interfaceId || super.supportsInterface(interfaceID); } function updateCoreWrapper(address _coreWrapper) public onlyOwner { coreWrapper = _coreWrapper; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; /* * @dev A parameter object containing data for bridging funds and an between chains */ struct LzBridgeData { uint120 _srcPoolId; uint120 _dstPoolId; uint16 _dstChainId; address _bridgeAddress; uint96 fee; } /* * @dev A parameter object containing token swap data and a payment transaction payload */ struct TokenData { uint256 amountIn; uint256 amountOut; uint256 nativeOut; address tokenIn; address tokenOut; bytes path; bytes payload; } /* * @dev A parameter containing token permit data */ struct TokenPermitData { address to; uint256 feeERC20; uint256 feeNative; uint256 deadline; uint256 nonce; bytes signature; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; import {Types} from "../lens/Types.sol"; /** * @title IPublicationAction * @author Lens Protocol * * @notice This is the standard interface for all Lens-compatible Publication Actions. * Publication action modules allow users to execute actions directly from a publication, like: * - Minting NFTs. * - Collecting a publication. * - Sending funds to the publication author (e.g. tipping). * - Etc. * Referrers are supported, so any publication or profile that references the publication can receive a share from the * publication's action if the action module supports it. */ interface IPublicationActionModule { /** * @notice Initializes the action module for the given publication being published with this Action module. * @custom:permissions LensHub. * * @param profileId The profile ID of the author publishing the content with this Publication Action. * @param pubId The publication ID being published. * @param transactionExecutor The address of the transaction executor (e.g. for any funds to transferFrom). * @param data Arbitrary data passed from the user to be decoded by the Action Module during initialization. * * @return bytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by * indexers or UIs. */ function initializePublicationAction( uint256 profileId, uint256 pubId, address transactionExecutor, bytes calldata data ) external returns (bytes memory); /** * @notice Processes the action for a given publication. This includes the action's logic and any monetary/token * operations. * @custom:permissions LensHub. * * @param processActionParams The parameters needed to execute the publication action. * * @return bytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by * indexers or UIs. */ function processPublicationAction(Types.ProcessActionParams calldata processActionParams) external returns (bytes memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; pragma abicoder v2; interface IStargateRouter { struct lzTxObj { uint256 dstGasForCall; uint256 dstNativeAmount; bytes dstNativeAddr; } function addLiquidity(uint256 _poolId, uint256 _amountLD, address _to) external; function swap( uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress, uint256 _amountLD, uint256 _minAmountLD, lzTxObj memory _lzTxParams, bytes calldata _to, bytes calldata _payload ) external payable; function redeemRemote( uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress, uint256 _amountLP, uint256 _minAmountLD, bytes calldata _to, lzTxObj memory _lzTxParams ) external payable; function instantRedeemLocal(uint16 _srcPoolId, uint256 _amountLP, address _to) external returns (uint256); function redeemLocal( uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress, uint256 _amountLP, bytes calldata _to, lzTxObj memory _lzTxParams ) external payable; function sendCredits(uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress) external payable; function quoteLayerZeroFee( uint16 _dstChainId, uint8 _functionType, bytes calldata _toAddress, bytes calldata _transferAndCallPayload, lzTxObj memory _lzTxParams ) external view returns (uint256, uint256); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; import {ICore} from "./interfaces/ICore.sol"; import {IERC20} from "@openzeppelin-contracts/contracts/interfaces/IERC20.sol"; import {SafeERC20} from "@openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {LzBridgeData, TokenData, TokenPermitData} from "./lib/CoreStructs.sol"; import {IStargateRouter} from "./interfaces/stargate/IStargateRouter.sol"; import {IWrappedToken} from "./interfaces/IWrappedToken.sol"; import {FeeOperator} from "./utils/FeeOperator.sol"; import {Context} from "@openzeppelin-contracts/contracts/utils/Context.sol"; import {ERC2771Context} from "@openzeppelin-contracts/contracts/metatx/ERC2771Context.sol"; import {Ownable} from "@openzeppelin-contracts/contracts/access/Ownable.sol"; import {IERC20Permit} from "@openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Permit.sol"; import {ISwapRouter} from "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; import {IPermit2} from "./interfaces/IPermit2.sol"; contract CoreWrapper is ERC2771Context, Ownable { address public core; // address public token; address public permit2; address public uniswapRouter; address public wrappedNative; address public trustedForwarder; constructor(address _trustedForwarder) ERC2771Context(_trustedForwarder) { trustedForwarder = _trustedForwarder; } function setFields(address _core, address _permit2, address _uniswapRouter, address _wrappedNative) public onlyOwner { core = _core; permit2 = _permit2; uniswapRouter = _uniswapRouter; wrappedNative = _wrappedNative; } function bridgeAndExecute( TokenPermitData calldata tokenPermitData, LzBridgeData calldata lzBridgeData, TokenData calldata tokenData, IStargateRouter.lzTxObj calldata lzTxObj ) external { // fetch token // if a user is calling this, they should pass in signature if (tokenPermitData.signature.length > 0) { IPermit2(tokenData.tokenIn).permitTransferFrom( // The permit message. IPermit2.PermitTransferFrom({ permitted: IPermit2.TokenPermissions({ token: IERC20(tokenData.tokenIn), amount: tokenData.amountIn + tokenPermitData.feeERC20 }), nonce: tokenPermitData.nonce, deadline: tokenPermitData.deadline }), // The transfer recipient and amount. IPermit2.SignatureTransferDetails({ to: address(this), requestedAmount: tokenData.amountIn + tokenPermitData.feeERC20 }), // The owner of the tokens, which must also be // the signer of the message, otherwise this call // will fail. _msgSender(), // The packed signature that was the result of signing // the EIP712 hash of `permit`. tokenPermitData.signature ); } else if (tokenData.amountIn + tokenPermitData.feeERC20 != 0) { SafeERC20.safeTransferFrom( IERC20(tokenData.tokenIn), _msgSender(), address(this), tokenData.amountIn + tokenPermitData.feeERC20 ); } // swap token + refund excess _convertFees(tokenData.tokenIn, tokenPermitData.feeERC20, tokenPermitData.feeNative, tokenPermitData.deadline); // approve core to use token if (tokenData.amountIn != 0) { SafeERC20.safeIncreaseAllowance(IERC20(tokenData.tokenIn), core, tokenData.amountIn); } // call bridgeAndExecute ICore(core).bridgeAndExecute{value: tokenPermitData.feeNative}(lzBridgeData, tokenData, lzTxObj); } function swapAndExecute( TokenPermitData calldata tokenPermitData, address target, address paymentOperator, TokenData calldata tokenData ) external { // require(address(token) == tokenData.tokenIn, "GaslessNFT.mint: incorrect tokenIn"); // fetch token // IERC20Permit(token).permit( // _msgSender(), // address(this), // tokenData.amountIn + tokenPermitData.feeERC20, // tokenPermitData.deadline, // tokenPermitData.v, // tokenPermitData.r, // tokenPermitData.s // ); if (tokenPermitData.signature.length > 0) { IPermit2(tokenData.tokenIn).permitTransferFrom( // The permit message. IPermit2.PermitTransferFrom({ permitted: IPermit2.TokenPermissions({ token: IERC20(tokenData.tokenIn), amount: tokenData.amountIn + tokenPermitData.feeERC20 }), nonce: tokenPermitData.nonce, deadline: tokenPermitData.deadline }), // The transfer recipient and amount. IPermit2.SignatureTransferDetails({ to: address(this), requestedAmount: tokenData.amountIn + tokenPermitData.feeERC20 }), // The owner of the tokens, which must also be // the signer of the message, otherwise this call // will fail. _msgSender(), // The packed signature that was the result of signing // the EIP712 hash of `permit`. tokenPermitData.signature ); } else if (tokenData.amountIn + tokenPermitData.feeERC20 != 0) { SafeERC20.safeTransferFrom( IERC20(tokenData.tokenIn), _msgSender(), address(this), tokenData.amountIn + tokenPermitData.feeERC20 ); } // swap token + refund excess _convertFees(tokenData.tokenIn, tokenPermitData.feeERC20, tokenPermitData.feeNative, tokenPermitData.deadline); // approve core to use token if (tokenData.amountIn != 0) { SafeERC20.safeIncreaseAllowance(IERC20(tokenData.tokenIn), core, tokenData.amountIn); } // call swapAndExecute ICore(core).swapAndExecute{value: tokenPermitData.feeNative}(target, paymentOperator, tokenData); } function _convertFees(address token, uint256 feeERC20, uint256 feeNative, uint256 deadline) internal { // swap usdc to native if (feeNative != 0) { if (token != wrappedNative) { _exactOut(token, feeERC20, feeNative, deadline); } IWrappedToken(wrappedNative).withdraw(feeNative); } } function _exactOut(address token, uint256 amountInMaximum, uint256 amountOut, uint256 deadline) internal { // wmatic <-> input token pool bytes memory path = abi.encodePacked(wrappedNative, uint24(500), token); // approve router to use our usdc SafeERC20.safeIncreaseAllowance(IERC20(token), uniswapRouter, amountInMaximum); // setup the parameters for swap ISwapRouter.ExactOutputParams memory params = ISwapRouter.ExactOutputParams({ path: path, recipient: address(this), deadline: deadline, amountOut: amountOut, amountInMaximum: amountInMaximum }); // perform the swap and calculate any excess erc20 funds uint256 amountIn = ISwapRouter(uniswapRouter).exactOutput(params); uint256 refund = amountInMaximum - amountIn; // refund any excess erc20 funds to sender if (refund > 0) { SafeERC20.safeDecreaseAllowance(IERC20(token), uniswapRouter, refund); SafeERC20.safeTransfer(IERC20(token), _msgSender(), refund); } } function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) { return ERC2771Context._msgSender(); } function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) { return ERC2771Context._msgData(); } receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title Types * @author Lens Protocol * * @notice A standard library of data types used throughout the Lens Protocol. */ library Types { /** * @notice ERC721Timestamped storage. Contains the owner address and the mint timestamp for every NFT. * * Note: Instead of the owner address in the _tokenOwners private mapping, we now store it in the * _tokenData mapping, alongside the mint timestamp. * * @param owner The token owner. * @param mintTimestamp The mint timestamp. */ struct TokenData { address owner; uint96 mintTimestamp; } /** * @notice A struct containing token follow-related data. * * @param followerProfileId The ID of the profile using the token to follow. * @param originalFollowTimestamp The timestamp of the first follow performed with the token. * @param followTimestamp The timestamp of the current follow, if a profile is using the token to follow. * @param profileIdAllowedToRecover The ID of the profile allowed to recover the follow ID, if any. */ struct FollowData { uint160 followerProfileId; uint48 originalFollowTimestamp; uint48 followTimestamp; uint256 profileIdAllowedToRecover; } /** * @notice An enum containing the different states the protocol can be in, limiting certain actions. * * @param Unpaused The fully unpaused state. * @param PublishingPaused The state where only publication creation functions are paused. * @param Paused The fully paused state. */ enum ProtocolState // TODO: Reverse order, so Paused becomes 0 and the default. This will get rid of the initializer needs. // It needs to be done carefully, as it might pause the protocol in the Lens V2 upgrade. { Unpaused, PublishingPaused, Paused } /** * @notice An enum specifically used in a helper function to easily retrieve the publication type for integrations. * * @param Nonexistent An indicator showing the queried publication does not exist. * @param Post A standard post, having an URI, action modules and no pointer to another publication. * @param Comment A comment, having an URI, action modules and a pointer to another publication. * @param Mirror A mirror, having a pointer to another publication, but no URI or action modules. * @param Quote A quote, having an URI, action modules, and a pointer to another publication. */ enum PublicationType { Nonexistent, Post, Comment, Mirror, Quote } /** * @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature. * * @param signer The address of the signer. Specially needed as a parameter to support EIP-1271. * @param v The signature's recovery parameter. * @param r The signature's r parameter. * @param s The signature's s parameter. * @param deadline The signature's deadline. */ struct EIP712Signature { address signer; uint8 v; bytes32 r; bytes32 s; uint256 deadline; } /** * @notice A struct containing profile data. * * @param pubCount The number of publications made to this profile. * @param followModule The address of the current follow module in use by this profile, can be address(0) in none. * @param followNFT The address of the followNFT associated with this profile. It can be address(0) if the * profile has not been followed yet, as the collection is lazy-deployed upon the first follow. * @param __DEPRECATED__handle DEPRECATED in V2: handle slot, was replaced with LensHandles. * @param __DEPRECATED__imageURI DEPRECATED in V2: The URI to be used for the profile image. * @param __DEPRECATED__followNFTURI DEPRECATED in V2: The URI used for the follow NFT image. * @param metadataURI MetadataURI is used to store the profile's metadata, for example: displayed name, description, * interests, etc. * @param metadataURI The URI to be used for the profile's metadata. */ struct Profile { uint256 pubCount; // offset 0 address followModule; // offset 1 address followNFT; // offset 2 string __DEPRECATED__handle; // offset 3 string __DEPRECATED__imageURI; // offset 4 string __DEPRECATED__followNFTURI; // Deprecated in V2 as we have a common tokenURI for all Follows, offset 5 string metadataURI; // offset 6 } /** * @notice A struct containing publication data. * * @param pointedProfileId The profile token ID to point the publication to. * @param pointedPubId The publication ID to point the publication to. * These are used to implement the "reference" feature of the platform and is used in: * - Mirrors * - Comments * - Quotes * There are (0,0) if the publication is not pointing to any other publication (i.e. the publication is a Post). * @param contentURI The URI to set for the content of publication (can be ipfs, arweave, http, etc). * @param referenceModule Reference module associated with this profile, if any. * @param __DEPRECATED__collectModule Collect module associated with this publication, if any. Deprecated in V2. * @param __DEPRECATED__collectNFT Collect NFT associated with this publication, if any. Deprecated in V2. * @param pubType The type of publication, can be Nonexistent, Post, Comment, Mirror or Quote. * @param rootProfileId The profile ID of the root post (to determine if comments/quotes and mirrors come from it). * Posts, V1 publications and publications rooted in V1 publications don't have it set. * @param rootPubId The publication ID of the root post (to determine if comments/quotes and mirrors come from it). * Posts, V1 publications and publications rooted in V1 publications don't have it set. * @param actionModuleEnabled The action modules enabled in a given publication. */ struct Publication { uint256 pointedProfileId; uint256 pointedPubId; string contentURI; address referenceModule; address __DEPRECATED__collectModule; // Deprecated in V2 address __DEPRECATED__collectNFT; // Deprecated in V2 // Added in Lens V2, so these will be zero for old publications: PublicationType pubType; uint256 rootProfileId; uint256 rootPubId; mapping(address => bool) actionModuleEnabled; } struct PublicationMemory { uint256 pointedProfileId; uint256 pointedPubId; string contentURI; address referenceModule; address __DEPRECATED__collectModule; // Deprecated in V2 address __DEPRECATED__collectNFT; // Deprecated in V2 // Added in Lens V2, so these will be zero for old publications: PublicationType pubType; uint256 rootProfileId; uint256 rootPubId; } // bytes32 __ACTION_MODULE_ENABLED_MAPPING; // Mappings are not supported in memory. /** * @notice A struct containing the parameters required for the `createProfile()` function. * * @param to The address receiving the profile. * @param followModule The follow module to use, can be the zero address. * @param followModuleInitData The follow module initialization data, if any. */ struct CreateProfileParams { address to; address followModule; bytes followModuleInitData; } /** * @notice A struct containing the parameters required for the `post()` function. * * @param profileId The token ID of the profile to publish to. * @param contentURI The URI to set for this new publication. * @param actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' initialization. * @param referenceModule The reference module to set for the given publication, must be whitelisted. * @param referenceModuleInitData The data to be passed to the reference module for initialization. */ struct PostParams { uint256 profileId; string contentURI; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @notice A struct containing the parameters required for the `comment()` function. * * @param profileId The token ID of the profile to publish to. * @param contentURI The URI to set for this new publication. * @param pointedProfileId The profile token ID to point the comment to. * @param pointedPubId The publication ID to point the comment to. * @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted. * @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted. * @param referenceModuleData The data passed to the reference module. * @param actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' initialization. * @param referenceModule The reference module to set for the given publication, must be whitelisted. * @param referenceModuleInitData The data to be passed to the reference module for initialization. */ struct CommentParams { uint256 profileId; string contentURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @notice A struct containing the parameters required for the `quote()` function. * * @param profileId The token ID of the profile to publish to. * @param contentURI The URI to set for this new publication. * @param pointedProfileId The profile token ID of the publication author that is quoted. * @param pointedPubId The publication ID that is quoted. * @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted. * @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted. * @param referenceModuleData The data passed to the reference module. * @param actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' initialization. * @param referenceModule The reference module to set for the given publication, must be whitelisted. * @param referenceModuleInitData The data to be passed to the reference module for initialization. */ struct QuoteParams { uint256 profileId; string contentURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @notice A struct containing the parameters required for the `comment()` or `quote()` internal functions. * * @param profileId The token ID of the profile to publish to. * @param contentURI The URI to set for this new publication. * @param pointedProfileId The profile token ID of the publication author that is commented on/quoted. * @param pointedPubId The publication ID that is commented on/quoted. * @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted. * @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted. * @param referenceModuleData The data passed to the reference module. * @param actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' initialization. * @param referenceModule The reference module to set for the given publication, must be whitelisted. * @param referenceModuleInitData The data to be passed to the reference module for initialization. */ struct ReferencePubParams { uint256 profileId; string contentURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @notice A struct containing the parameters required for the `mirror()` function. * * @param profileId The token ID of the profile to publish to. * @param metadataURI the URI containing metadata attributes to attach to this mirror publication. * @param pointedProfileId The profile token ID to point the mirror to. * @param pointedPubId The publication ID to point the mirror to. * @param referenceModuleData The data passed to the reference module. */ struct MirrorParams { uint256 profileId; string metadataURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; } /** * Deprecated in V2: Will be removed after some time after upgrading to V2. * @notice A struct containing the parameters required for the legacy `collect()` function. * @dev The referrer can only be a mirror of the publication being collected. * * @param publicationCollectedProfileId The token ID of the profile that published the publication to collect. * @param publicationCollectedId The publication to collect's publication ID. * @param collectorProfileId The collector profile. * @param referrerProfileId The ID of a profile that authored a mirror that helped discovering the collected pub. * @param referrerPubId The ID of the mirror that helped discovering the collected pub. * @param collectModuleData The arbitrary data to pass to the collectModule if needed. */ struct LegacyCollectParams { uint256 publicationCollectedProfileId; uint256 publicationCollectedId; uint256 collectorProfileId; uint256 referrerProfileId; uint256 referrerPubId; bytes collectModuleData; } /** * @notice A struct containing the parameters required for the `action()` function. * * @param publicationActedProfileId The token ID of the profile that published the publication to action. * @param publicationActedId The publication to action's publication ID. * @param actorProfileId The actor profile. * @param referrerProfileId * @param referrerPubId * @param actionModuleAddress * @param actionModuleData The arbitrary data to pass to the actionModule if needed. */ struct PublicationActionParams { uint256 publicationActedProfileId; uint256 publicationActedId; uint256 actorProfileId; uint256[] referrerProfileIds; uint256[] referrerPubIds; address actionModuleAddress; bytes actionModuleData; } struct ProcessActionParams { uint256 publicationActedProfileId; uint256 publicationActedId; uint256 actorProfileId; address actorProfileOwner; address transactionExecutor; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes actionModuleData; } // TODO: Shouldn't this be in the modules Types? struct ProcessCollectParams { uint256 publicationCollectedProfileId; uint256 publicationCollectedId; uint256 collectorProfileId; address collectorProfileOwner; address transactionExecutor; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes data; } struct ProcessCommentParams { uint256 profileId; address transactionExecutor; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes data; } struct ProcessQuoteParams { uint256 profileId; address transactionExecutor; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes data; } struct ProcessMirrorParams { uint256 profileId; address transactionExecutor; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes data; } /** * @notice A struct containing a profile's delegated executors configuration. * * @param isApproved Tells when an address is approved as delegated executor in the given configuration number. * @param configNumber Current configuration number in use. * @param prevConfigNumber Previous configuration number set, before switching to the current one. * @param maxConfigNumberSet Maximum configuration number ever used. */ struct DelegatedExecutorsConfig { mapping(uint256 => mapping(address => bool)) isApproved; // isApproved[configNumber][delegatedExecutor] uint64 configNumber; uint64 prevConfigNumber; uint64 maxConfigNumberSet; } struct TreasuryData { address treasury; uint16 treasuryFeeBPS; } struct MigrationParams { address lensHandlesAddress; address tokenHandleRegistryAddress; address legacyFeeFollowModule; address legacyProfileFollowModule; address newFeeFollowModule; address migrationAdmin; } } struct InitializedAction { address targetContract; address paymentToken; uint256 chainId; uint256 cost; bytes signature; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import {Errors} from "./Errors.sol"; /** * @title HubRestricted * @author Lens Protocol * * @notice This abstract contract adds a public `HUB` immutable field, as well as an `onlyHub` modifier, * to inherit from contracts that have functions restricted to be only called by the Lens hub. */ abstract contract HubRestricted { address public immutable HUB; modifier onlyHub() { if (msg.sender != HUB) { revert Errors.NotHub(); } _; } constructor(address hub) { HUB = hub; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @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); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to * 0 before setting it to a non-zero value. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * 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.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {Ownable} from "@openzeppelin-contracts/contracts/access/Ownable.sol"; import {LensModule} from "./LensModule.sol"; contract LensModuleMetadata is LensModule, Ownable { string public metadataURI; constructor(string memory _metadataURI) { metadataURI = _metadataURI; } function setModuleMetadataURI(string memory _metadataURI) external onlyOwner { metadataURI = _metadataURI; } function getModuleMetadataURI() external view returns (string memory) { return metadataURI; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; import {LzBridgeData, TokenData} from "../lib/CoreStructs.sol"; import {IStargateRouter} from "../interfaces/stargate/IStargateRouter.sol"; interface ICore { /* * @dev Only Stargate Router can perform this operation. */ error OnlyStargateRouter(); /** * @dev Swaps currency from the incoming to the outgoing token and executes a transaction with payment. * @param target The address of the target contract for the payment transaction. * @param paymentOperator The operator address for payment transfers requiring erc20 approvals. * @param tokenData The token swap data and payment transaction payload */ function swapAndExecute(address target, address paymentOperator, TokenData calldata tokenData) external payable; /** * @dev Bridges funds in native or erc20 and a payment transaction payload to the destination chain * @param lzBridgeData The configuration for the cross bridge transaction * @param tokenData The token swap data and payment transaction payload * @param lzTxObj The configuration of gas and dust for post bridge execution */ function bridgeAndExecute( LzBridgeData calldata lzBridgeData, TokenData calldata tokenData, IStargateRouter.lzTxObj calldata lzTxObj ) external payable; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; interface IWrappedToken { function withdraw(uint256 wad) external; function deposit() external payable; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; import "../interfaces/IFeeManager.sol"; import {Ownable} from "@openzeppelin-contracts/contracts/access/Ownable.sol"; /** * @title FeeOperator */ abstract contract FeeOperator is Ownable { /* * @dev The address of the fee manager. */ address public feeManager; /* * @dev Emitted when the fee manager is updated. * @param feeManager The address of the new fee manager. */ event FeeManagerUpdated(address feeManager); /* * @dev Insufficient funds to complete the transaction and pay fees. */ error InsufficientFees(); /* * @dev Fees were unable to be transferred to the fee manager. */ error FeeTransferFailed(); /* * @dev Excess funds were unable to be refunded to the caller. */ error RefundFailed(); /** * @dev Function modifier to handle transaction fees for bridging and swapping. * @param bridgeFee The amount of native being transferred to the bridge protocol. * @param amountIn The amount of native or erc20 being transferred. * @param tokenIn The address of the token being transferred, zero address for native currency. * @param nativeOut The amount of unwrapped native being transferred. */ modifier handleFees(uint256 bridgeFee, uint256 amountIn, address tokenIn, uint256 nativeOut) { if (feeManager != address(0)) { (uint256 fee, uint256 commission) = IFeeManager(feeManager).calculateFees(amountIn, tokenIn); uint256 boxFees = fee + commission; uint256 amountRequired = tokenIn == address(0) ? amountIn + nativeOut + bridgeFee + boxFees : nativeOut + bridgeFee + boxFees; if (msg.value < amountRequired) { revert InsufficientFees(); } _transferFees(boxFees); _transferRefund(msg.value - amountRequired); } _; } /** * @dev Updates the address of the fee manager used for calculating and collecting fees. * @param _feeManager The address of the new fee manager. */ function setFeeManager(address _feeManager) external onlyOwner { feeManager = _feeManager; emit FeeManagerUpdated(_feeManager); } /** * @dev Internal function to transfer fees to the fee manager. * @param fees The amount of fees being transferred. */ function _transferFees(uint256 fees) internal { (bool success,) = payable(feeManager).call{value: fees}(""); if (!success) { revert FeeTransferFailed(); } } /** * @dev Internal function to transfer excess funds to the caller. * @param refund The amount of funds to transfer. */ function _transferRefund(uint256 refund) internal { if (refund > 0) { (bool success,) = payable(_msgSender()).call{value: refund}(""); if (!success) { revert RefundFailed(); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol) pragma solidity ^0.8.9; import "../utils/Context.sol"; /** * @dev Context variant with ERC2771 support. */ abstract contract ERC2771Context is Context { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable _trustedForwarder; /// @custom:oz-upgrades-unsafe-allow constructor constructor(address trustedForwarder) { _trustedForwarder = trustedForwarder; } function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return forwarder == _trustedForwarder; } function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. /// @solidity memory-safe-assembly assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - 20]; } else { return super._msgData(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.0; import "./IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/cryptography/EIP712.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation 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. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import {IERC20} from "@openzeppelin-contracts/contracts/interfaces/IERC20.sol"; // Minimal Permit2 interface, derived from // https://github.com/Uniswap/permit2/blob/main/src/interfaces/ISignatureTransfer.sol interface IPermit2 { // Token and amount in a permit message. struct TokenPermissions { // Token to transfer. IERC20 token; // Amount to transfer. uint256 amount; } // The permit2 message. struct PermitTransferFrom { // Permitted token and amount. TokenPermissions permitted; // Unique identifier for this permit. uint256 nonce; // Expiration for this permit. uint256 deadline; } // Transfer details for permitTransferFrom(). struct SignatureTransferDetails { // Recipient of tokens. address to; // Amount to transfer. uint256 requestedAmount; } // Consume a permit2 message and transfer tokens. function permitTransferFrom( PermitTransferFrom calldata permit, SignatureTransferDetails calldata transferDetails, address owner, bytes calldata signature ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; library Errors { error CannotInitImplementation(); error Initialized(); error SignatureExpired(); error SignatureInvalid(); error InvalidOwner(); error NotOwnerOrApproved(); error NotHub(); error TokenDoesNotExist(); error NotGovernance(); error NotGovernanceOrEmergencyAdmin(); error EmergencyAdminCanOnlyPauseFurther(); error NotProfileOwner(); error PublicationDoesNotExist(); error CallerNotFollowNFT(); error CallerNotCollectNFT(); // Legacy error ArrayMismatch(); error NotWhitelisted(); error NotRegistered(); error InvalidParameter(); error ExecutorInvalid(); error Blocked(); error SelfBlock(); error NotFollowing(); error SelfFollow(); error InvalidReferrer(); error InvalidPointedPub(); error NonERC721ReceiverImplementer(); error AlreadyEnabled(); // Module Errors error InitParamsInvalid(); error ActionNotAllowed(); error CollectNotAllowed(); // Used in LegacyCollectLib (pending deprecation) // MultiState Errors error Paused(); error PublishingPaused(); // Profile Guardian Errors error GuardianEnabled(); error NotEOA(); error DisablingAlreadyTriggered(); // Migration Errors error NotMigrationAdmin(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {ILensModule} from "../interfaces/ILensModule.sol"; abstract contract LensModule is ILensModule { /// @inheritdoc ILensModule function supportsInterface(bytes4 interfaceID) public pure virtual override returns (bool) { return interfaceID == bytes4(keccak256(abi.encodePacked("LENS_MODULE"))); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; interface IFeeManager { error WithdrawFailed(); function setFees(uint256 _fee, uint256 _commissionBPS) external; function calculateFees(uint256 amountIn, address tokenIn) external view returns (uint256 fee, uint256 commission); function redeemFees() external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.8; import "./ECDSA.sol"; import "../ShortStrings.sol"; import "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * _Available since v3.4._ * * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {EIP-5267}. */ function eip712Domain() public view virtual override returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _name.toStringWithFallback(_nameFallback), _version.toStringWithFallback(_versionFallback), block.chainid, address(this), bytes32(0), new uint256[](0) ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {IERC165} from "@openzeppelin-contracts/contracts/utils/introspection/IERC165.sol"; interface ILensModule is IERC165 { /// @dev for now we check for keccak('LENS_MODULE'); /// Override this and add the type(IModuleInterface).interfaceId for corresponding module type function supportsInterface(bytes4 interfaceID) external view returns (bool); /// @notice Human-readable description of the module // Can be JSON // Can be contract source code // Can be github link // Can be ipfs with documentation // etc function getModuleMetadataURI() external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import "./StorageSlot.sol"; type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * Strings of arbitrary length can be optimized if they are short enough by * the addition of a storage variable used as fallback. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(_FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._ * _Available since v4.9 for `string`, `bytes`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
{ "remappings": [ "@openzeppelin-contracts/=lib/openzeppelin-contracts/", "solmate/=lib/solmate/src/", "@uniswap/v3-periphery/=lib/v3-periphery/", "@uniswap/v3-core/=lib/v3-core/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "v3-core/=lib/v3-core/", "v3-periphery/=lib/v3-periphery/contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_coreWrapper","type":"address"},{"internalType":"address","name":"_lensHubProxyContract","type":"address"},{"internalType":"string","name":"_metadataURI","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WrongBoxArgs","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"address","name":"transactionExecutor","type":"address"}],"name":"InitializedPublicationAction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"publicationActedProfileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"publicationActedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"actorProfileId","type":"uint256"},{"indexed":false,"internalType":"address","name":"actorProfileOwner","type":"address"}],"name":"ProcessedPublicationAction","type":"event"},{"inputs":[],"name":"HUB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"coreWrapper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModuleMetadataURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"address","name":"transactionExecutor","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initializePublicationAction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"metadataURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"publicationActedProfileId","type":"uint256"},{"internalType":"uint256","name":"publicationActedId","type":"uint256"},{"internalType":"uint256","name":"actorProfileId","type":"uint256"},{"internalType":"address","name":"actorProfileOwner","type":"address"},{"internalType":"address","name":"transactionExecutor","type":"address"},{"internalType":"uint256[]","name":"referrerProfileIds","type":"uint256[]"},{"internalType":"uint256[]","name":"referrerPubIds","type":"uint256[]"},{"internalType":"enum Types.PublicationType[]","name":"referrerPubTypes","type":"uint8[]"},{"internalType":"bytes","name":"actionModuleData","type":"bytes"}],"internalType":"struct Types.ProcessActionParams","name":"params","type":"tuple"}],"name":"processPublicationAction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"pubActions","outputs":[{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_metadataURI","type":"string"}],"name":"setModuleMetadataURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_coreWrapper","type":"address"}],"name":"updateCoreWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a06040523480156200001157600080fd5b5060405162001e5738038062001e5783398101604081905262000034916200010a565b6001600160a01b038216608052806200004d3362000087565b60016200005b828262000293565b5050600280546001600160a01b0319166001600160a01b039490941693909317909255506200035f9050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000ef57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156200012057600080fd5b6200012b84620000d7565b925060206200013c818601620000d7565b60408601519093506001600160401b03808211156200015a57600080fd5b818701915087601f8301126200016f57600080fd5b815181811115620001845762000184620000f4565b604051601f8201601f19908116603f01168101908382118183101715620001af57620001af620000f4565b816040528281528a86848701011115620001c857600080fd5b600093505b82841015620001ec5784840186015181850187015292850192620001cd565b60008684830101528096505050505050509250925092565b600181811c908216806200021957607f821691505b6020821081036200023a57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200028e57600081815260208120601f850160051c81016020861015620002695750805b601f850160051c820191505b818110156200028a5782815560010162000275565b5050505b505050565b81516001600160401b03811115620002af57620002af620000f4565b620002c781620002c0845462000204565b8462000240565b602080601f831160018114620002ff5760008415620002e65750858301515b600019600386901b1c1916600185901b1785556200028a565b600085815260208120601f198616915b8281101562000330578886015182559484019460019091019084016200030f565b50858210156200034f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b608051611adc6200037b60003960006101a20152611adc6000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638da5cb5b1161008c578063ce90d52e11610066578063ce90d52e146101c4578063e2f0edf3146101cc578063f2fde38b146101df578063f3f88df5146101f257600080fd5b80638da5cb5b1461016557806390ce6e081461018a578063a4c52b861461019d57600080fd5b806301ffc9a7146100d457806303ee438c146100fc5780630b960220146101115780631a6fb6c514610124578063681591c114610148578063715018a61461015d575b600080fd5b6100e76100e2366004610e5f565b610205565b60405190151581526020015b60405180910390f35b61010461026a565b6040516100f39190610ee0565b61010461011f366004610f18565b6102f8565b610137610132366004610fad565b610488565b6040516100f3959493929190610fcf565b61015b6101563660046110fe565b610556565b005b61015b61056e565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100f3565b610104610198366004611146565b610582565b6101727f000000000000000000000000000000000000000000000000000000000000000081565b61010461067b565b600254610172906001600160a01b031681565b61015b6101ed366004611181565b61070d565b61015b610200366004611181565b61078b565b60006001600160e01b0319821663136b0d8560e31b14806102645750604080516a4c454e535f4d4f44554c4560a81b6020808301919091528251600b818403018152602b90920190925280519101206001600160e01b03198381169116145b92915050565b600180546102779061119e565b80601f01602080910402602001604051908101604052809291908181526020018280546102a39061119e565b80156102f05780601f106102c5576101008083540402835291602001916102f0565b820191906000526020600020905b8154815290600101906020018083116102d357829003601f168201915b505050505081565b606060008080808061030c878901896111f8565b945094509450945094506040518060a00160405280866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200182815250600360008d815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550604082015181600201556060820151816003015560808201518160040190816103f691906112bb565b5050604080518d8152602081018d90526001600160a01b038c168183015290517fca8057e7deba16092420065e2478160594e94591c0f7b574514614bbf216da8d92509081900360600190a187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929e9d5050505050505050505050505050565b60036020818152600093845260408085209091529183529120805460018201546002830154938301546004840180546001600160a01b0394851696949093169491926104d39061119e565b80601f01602080910402602001604051908101604052809291908181526020018280546104ff9061119e565b801561054c5780601f106105215761010080835404028352916020019161054c565b820191906000526020600020905b81548152906001019060200180831161052f57829003601f168201915b5050505050905085565b61055e6107b5565b600161056a82826112bb565b5050565b6105766107b5565b610580600061080f565b565b6060600061059461010084018461137a565b905011156105c9576105c96105ad61010084018461137a565b6105bd60a0860160808701611181565b8535602087013561085f565b7f0e534ce06df04359fab57a1fdb50bc4b7c1ae1b109a1ddfa71e65386efcbbccd8235602084013560408501356106066080870160608801611181565b604080519485526020850193909352918301526001600160a01b0316606082015260800160405180910390a161064061010083018361137a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295945050505050565b60606001805461068a9061119e565b80601f01602080910402602001604051908101604052809291908181526020018280546106b69061119e565b80156107035780601f106106d857610100808354040283529160200191610703565b820191906000526020600020905b8154815290600101906020018083116106e657829003601f168201915b5050505050905090565b6107156107b5565b6001600160a01b03811661077f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6107888161080f565b50565b6107936107b5565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146105805760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610776565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008281526003602090815260408083208484529091529020600201544614610961576000808080610893888a018a6115b7565b9450945094509450506000808360c001518060200190518101906108b79190611726565b5050505092509250506108e284606001518a886020015187600001516108dd91906117e1565b610a1c565b6108ee81838a8a610a62565b600254604051630ae0575d60e11b81526001600160a01b03909116906315c0aeba906109249089908990899089906004016118f1565b600060405180830381600087803b15801561093e57600080fd5b505af1158015610952573d6000803e3d6000fd5b50505050505050505050610a15565b6000808080610972888a018a611983565b945094509450945050610998816060015188866020015184600001516108dd91906117e1565b6109a88160800151848888610a62565b60025460405163b71ad5d560e01b81526001600160a01b039091169063b71ad5d5906109de908790879087908790600401611a13565b600060405180830381600087803b1580156109f857600080fd5b505af1158015610a0c573d6000803e3d6000fd5b50505050505050505b5050505050565b6001600160a01b03831615801590610a345750600081115b15610a5d57610a4583833084610ae2565b600254610a5d9084906001600160a01b031683610b4d565b505050565b60008281526003602090815260408083208484529091529020600101546001600160a01b038581169116141580610abe575060008281526003602090815260408083208484529091529020546001600160a01b03848116911614155b15610adc576040516374b1fc2560e01b815260040160405180910390fd5b50505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610adc9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610bfa565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc19190611a4f565b9050610adc8463095ea7b360e01b85610bda86866117e1565b6040516001600160a01b0390921660248301526044820152606401610b16565b6000610c4f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610ccf9092919063ffffffff16565b9050805160001480610c70575080806020019051810190610c709190611a68565b610a5d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610776565b6060610cde8484600085610ce6565b949350505050565b606082471015610d475760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610776565b600080866001600160a01b03168587604051610d639190611a8a565b60006040518083038185875af1925050503d8060008114610da0576040519150601f19603f3d011682016040523d82523d6000602084013e610da5565b606091505b5091509150610db687838387610dc1565b979650505050505050565b60608315610e30578251600003610e29576001600160a01b0385163b610e295760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610776565b5081610cde565b610cde8383815115610e455781518083602001fd5b8060405162461bcd60e51b81526004016107769190610ee0565b600060208284031215610e7157600080fd5b81356001600160e01b031981168114610e8957600080fd5b9392505050565b60005b83811015610eab578181015183820152602001610e93565b50506000910152565b60008151808452610ecc816020860160208601610e90565b601f01601f19169290920160200192915050565b602081526000610e896020830184610eb4565b6001600160a01b038116811461078857600080fd5b8035610f1381610ef3565b919050565b600080600080600060808688031215610f3057600080fd5b85359450602086013593506040860135610f4981610ef3565b925060608601356001600160401b0380821115610f6557600080fd5b818801915088601f830112610f7957600080fd5b813581811115610f8857600080fd5b896020828501011115610f9a57600080fd5b9699959850939650602001949392505050565b60008060408385031215610fc057600080fd5b50508035926020909101359150565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090610db690830184610eb4565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b038111828210171561104157611041611009565b60405290565b60405160a081016001600160401b038111828210171561104157611041611009565b604051601f8201601f191681016001600160401b038111828210171561109157611091611009565b604052919050565b60006001600160401b038211156110b2576110b2611009565b50601f01601f191660200190565b60006110d36110ce84611099565b611069565b90508281528383830111156110e757600080fd5b828260208301376000602084830101529392505050565b60006020828403121561111057600080fd5b81356001600160401b0381111561112657600080fd5b8201601f8101841361113757600080fd5b610cde848235602084016110c0565b60006020828403121561115857600080fd5b81356001600160401b0381111561116e57600080fd5b82016101208185031215610e8957600080fd5b60006020828403121561119357600080fd5b8135610e8981610ef3565b600181811c908216806111b257607f821691505b6020821081036111d257634e487b7160e01b600052602260045260246000fd5b50919050565b600082601f8301126111e957600080fd5b610e89838335602085016110c0565b600080600080600060a0868803121561121057600080fd5b853561121b81610ef3565b9450602086013561122b81610ef3565b9350604086013592506060860135915060808601356001600160401b0381111561125457600080fd5b611260888289016111d8565b9150509295509295909350565b601f821115610a5d57600081815260208120601f850160051c810160208610156112945750805b601f850160051c820191505b818110156112b3578281556001016112a0565b505050505050565b81516001600160401b038111156112d4576112d4611009565b6112e8816112e2845461119e565b8461126d565b602080601f83116001811461131d57600084156113055750858301515b600019600386901b1c1916600185901b1785556112b3565b600085815260208120601f198616915b8281101561134c5788860151825594840194600190910190840161132d565b508582101561136a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000808335601e1984360301811261139157600080fd5b8301803591506001600160401b038211156113ab57600080fd5b6020019150368190038213156113c057600080fd5b9250929050565b803560ff81168114610f1357600080fd5b600060c082840312156113ea57600080fd5b60405160c081016001600160401b03828210818311171561140d5761140d611009565b816040528293508435915061142182610ef3565b8183526020850135602084015260408501356040840152606085013560608401526080850135608084015260a085013591508082111561146057600080fd5b5061146d858286016111d8565b60a0830152505092915050565b80356001600160781b0381168114610f1357600080fd5b600060e082840312156114a357600080fd5b6114ab61101f565b90508135815260208201356020820152604082013560408201526114d160608301610f08565b60608201526114e260808301610f08565b608082015260a08201356001600160401b038082111561150157600080fd5b61150d858386016111d8565b60a084015260c084013591508082111561152657600080fd5b50611533848285016111d8565b60c08301525092915050565b60006060828403121561155157600080fd5b604051606081016001600160401b03828210818311171561157457611574611009565b816040528293508435835260208501356020840152604085013591508082111561159d57600080fd5b506115aa858286016111d8565b6040830152505092915050565b60008060008060008587036101208112156115d157600080fd5b6115da876113c7565b955060208701356001600160401b03808211156115f657600080fd5b6116028a838b016113d8565b965060a0603f198401121561161657600080fd5b61161e611047565b925061162c60408a0161147a565b835261163a60608a0161147a565b60208401526080890135915061ffff8216821461165657600080fd5b81604084015260a0890135915061166c82610ef3565b81606084015260c089013591506bffffffffffffffffffffffff8216821461169357600080fd5b81608084015282955060e08901359250808311156116b057600080fd5b6116bc8a848b01611491565b94506101008901359250808311156116d357600080fd5b50506112608882890161153f565b600082601f8301126116f257600080fd5b81516117006110ce82611099565b81815284602083860101111561171557600080fd5b610cde826020830160208701610e90565b600080600080600080600060e0888a03121561174157600080fd5b875161174c81610ef3565b602089015190975061175d81610ef3565b604089015190965061176e81610ef3565b606089015190955061177f81610ef3565b608089015160a08a015191955093506001600160401b03808211156117a357600080fd5b6117af8b838c016116e1565b935060c08a01519150808211156117c557600080fd5b506117d28a828b016116e1565b91505092959891949750929550565b8082018082111561026457634e487b7160e01b600052601160045260246000fd5b60018060a01b03815116825260208101516020830152604081015160408301526060810151606083015260808101516080830152600060a082015160c060a0850152610cde60c0850182610eb4565b8051825260208101516020830152604081015160408301526000606082015160018060a01b038082166060860152806080850151166080860152505060a082015160e060a08501526118a660e0850182610eb4565b905060c083015184820360c08601526118bf8282610eb4565b95945050505050565b80518252602081015160208301526000604082015160606040850152610cde6060850182610eb4565b600061010080835261190581840188611802565b90506001600160781b038087511660208501528060208801511660408501525061ffff604087015116606084015260018060a01b0360608701511660808401526bffffffffffffffffffffffff60808701511660a084015282810360c084015261196f8186611851565b905082810360e0840152610db681856118c8565b600080600080600060a0868803121561199b57600080fd5b6119a4866113c7565b945060208601356001600160401b03808211156119c057600080fd5b6119cc89838a016113d8565b9550604088013591506119de82610ef3565b9093506060870135906119f082610ef3565b90925060808701359080821115611a0657600080fd5b5061126088828901611491565b608081526000611a266080830187611802565b6001600160a01b038681166020850152851660408401528281036060840152610db68185611851565b600060208284031215611a6157600080fd5b5051919050565b600060208284031215611a7a57600080fd5b81518015158114610e8957600080fd5b60008251611a9c818460208701610e90565b919091019291505056fea2646970667358221220b95d5b14a90e60218b27142c460ed6ab961e9e5555c8da89cc0a7b25d4a3e18d64736f6c634300081100330000000000000000000000001bcefd8a3067cdb0698993c15f2c62f001fc6222000000000000000000000000db46d1dc155634fbc732f92e853b10b288ad5a1d00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000009446563656e74204f410000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638da5cb5b1161008c578063ce90d52e11610066578063ce90d52e146101c4578063e2f0edf3146101cc578063f2fde38b146101df578063f3f88df5146101f257600080fd5b80638da5cb5b1461016557806390ce6e081461018a578063a4c52b861461019d57600080fd5b806301ffc9a7146100d457806303ee438c146100fc5780630b960220146101115780631a6fb6c514610124578063681591c114610148578063715018a61461015d575b600080fd5b6100e76100e2366004610e5f565b610205565b60405190151581526020015b60405180910390f35b61010461026a565b6040516100f39190610ee0565b61010461011f366004610f18565b6102f8565b610137610132366004610fad565b610488565b6040516100f3959493929190610fcf565b61015b6101563660046110fe565b610556565b005b61015b61056e565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100f3565b610104610198366004611146565b610582565b6101727f000000000000000000000000db46d1dc155634fbc732f92e853b10b288ad5a1d81565b61010461067b565b600254610172906001600160a01b031681565b61015b6101ed366004611181565b61070d565b61015b610200366004611181565b61078b565b60006001600160e01b0319821663136b0d8560e31b14806102645750604080516a4c454e535f4d4f44554c4560a81b6020808301919091528251600b818403018152602b90920190925280519101206001600160e01b03198381169116145b92915050565b600180546102779061119e565b80601f01602080910402602001604051908101604052809291908181526020018280546102a39061119e565b80156102f05780601f106102c5576101008083540402835291602001916102f0565b820191906000526020600020905b8154815290600101906020018083116102d357829003601f168201915b505050505081565b606060008080808061030c878901896111f8565b945094509450945094506040518060a00160405280866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200182815250600360008d815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550604082015181600201556060820151816003015560808201518160040190816103f691906112bb565b5050604080518d8152602081018d90526001600160a01b038c168183015290517fca8057e7deba16092420065e2478160594e94591c0f7b574514614bbf216da8d92509081900360600190a187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929e9d5050505050505050505050505050565b60036020818152600093845260408085209091529183529120805460018201546002830154938301546004840180546001600160a01b0394851696949093169491926104d39061119e565b80601f01602080910402602001604051908101604052809291908181526020018280546104ff9061119e565b801561054c5780601f106105215761010080835404028352916020019161054c565b820191906000526020600020905b81548152906001019060200180831161052f57829003601f168201915b5050505050905085565b61055e6107b5565b600161056a82826112bb565b5050565b6105766107b5565b610580600061080f565b565b6060600061059461010084018461137a565b905011156105c9576105c96105ad61010084018461137a565b6105bd60a0860160808701611181565b8535602087013561085f565b7f0e534ce06df04359fab57a1fdb50bc4b7c1ae1b109a1ddfa71e65386efcbbccd8235602084013560408501356106066080870160608801611181565b604080519485526020850193909352918301526001600160a01b0316606082015260800160405180910390a161064061010083018361137a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295945050505050565b60606001805461068a9061119e565b80601f01602080910402602001604051908101604052809291908181526020018280546106b69061119e565b80156107035780601f106106d857610100808354040283529160200191610703565b820191906000526020600020905b8154815290600101906020018083116106e657829003601f168201915b5050505050905090565b6107156107b5565b6001600160a01b03811661077f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6107888161080f565b50565b6107936107b5565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146105805760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610776565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008281526003602090815260408083208484529091529020600201544614610961576000808080610893888a018a6115b7565b9450945094509450506000808360c001518060200190518101906108b79190611726565b5050505092509250506108e284606001518a886020015187600001516108dd91906117e1565b610a1c565b6108ee81838a8a610a62565b600254604051630ae0575d60e11b81526001600160a01b03909116906315c0aeba906109249089908990899089906004016118f1565b600060405180830381600087803b15801561093e57600080fd5b505af1158015610952573d6000803e3d6000fd5b50505050505050505050610a15565b6000808080610972888a018a611983565b945094509450945050610998816060015188866020015184600001516108dd91906117e1565b6109a88160800151848888610a62565b60025460405163b71ad5d560e01b81526001600160a01b039091169063b71ad5d5906109de908790879087908790600401611a13565b600060405180830381600087803b1580156109f857600080fd5b505af1158015610a0c573d6000803e3d6000fd5b50505050505050505b5050505050565b6001600160a01b03831615801590610a345750600081115b15610a5d57610a4583833084610ae2565b600254610a5d9084906001600160a01b031683610b4d565b505050565b60008281526003602090815260408083208484529091529020600101546001600160a01b038581169116141580610abe575060008281526003602090815260408083208484529091529020546001600160a01b03848116911614155b15610adc576040516374b1fc2560e01b815260040160405180910390fd5b50505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610adc9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610bfa565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc19190611a4f565b9050610adc8463095ea7b360e01b85610bda86866117e1565b6040516001600160a01b0390921660248301526044820152606401610b16565b6000610c4f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610ccf9092919063ffffffff16565b9050805160001480610c70575080806020019051810190610c709190611a68565b610a5d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610776565b6060610cde8484600085610ce6565b949350505050565b606082471015610d475760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610776565b600080866001600160a01b03168587604051610d639190611a8a565b60006040518083038185875af1925050503d8060008114610da0576040519150601f19603f3d011682016040523d82523d6000602084013e610da5565b606091505b5091509150610db687838387610dc1565b979650505050505050565b60608315610e30578251600003610e29576001600160a01b0385163b610e295760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610776565b5081610cde565b610cde8383815115610e455781518083602001fd5b8060405162461bcd60e51b81526004016107769190610ee0565b600060208284031215610e7157600080fd5b81356001600160e01b031981168114610e8957600080fd5b9392505050565b60005b83811015610eab578181015183820152602001610e93565b50506000910152565b60008151808452610ecc816020860160208601610e90565b601f01601f19169290920160200192915050565b602081526000610e896020830184610eb4565b6001600160a01b038116811461078857600080fd5b8035610f1381610ef3565b919050565b600080600080600060808688031215610f3057600080fd5b85359450602086013593506040860135610f4981610ef3565b925060608601356001600160401b0380821115610f6557600080fd5b818801915088601f830112610f7957600080fd5b813581811115610f8857600080fd5b896020828501011115610f9a57600080fd5b9699959850939650602001949392505050565b60008060408385031215610fc057600080fd5b50508035926020909101359150565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090610db690830184610eb4565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b038111828210171561104157611041611009565b60405290565b60405160a081016001600160401b038111828210171561104157611041611009565b604051601f8201601f191681016001600160401b038111828210171561109157611091611009565b604052919050565b60006001600160401b038211156110b2576110b2611009565b50601f01601f191660200190565b60006110d36110ce84611099565b611069565b90508281528383830111156110e757600080fd5b828260208301376000602084830101529392505050565b60006020828403121561111057600080fd5b81356001600160401b0381111561112657600080fd5b8201601f8101841361113757600080fd5b610cde848235602084016110c0565b60006020828403121561115857600080fd5b81356001600160401b0381111561116e57600080fd5b82016101208185031215610e8957600080fd5b60006020828403121561119357600080fd5b8135610e8981610ef3565b600181811c908216806111b257607f821691505b6020821081036111d257634e487b7160e01b600052602260045260246000fd5b50919050565b600082601f8301126111e957600080fd5b610e89838335602085016110c0565b600080600080600060a0868803121561121057600080fd5b853561121b81610ef3565b9450602086013561122b81610ef3565b9350604086013592506060860135915060808601356001600160401b0381111561125457600080fd5b611260888289016111d8565b9150509295509295909350565b601f821115610a5d57600081815260208120601f850160051c810160208610156112945750805b601f850160051c820191505b818110156112b3578281556001016112a0565b505050505050565b81516001600160401b038111156112d4576112d4611009565b6112e8816112e2845461119e565b8461126d565b602080601f83116001811461131d57600084156113055750858301515b600019600386901b1c1916600185901b1785556112b3565b600085815260208120601f198616915b8281101561134c5788860151825594840194600190910190840161132d565b508582101561136a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000808335601e1984360301811261139157600080fd5b8301803591506001600160401b038211156113ab57600080fd5b6020019150368190038213156113c057600080fd5b9250929050565b803560ff81168114610f1357600080fd5b600060c082840312156113ea57600080fd5b60405160c081016001600160401b03828210818311171561140d5761140d611009565b816040528293508435915061142182610ef3565b8183526020850135602084015260408501356040840152606085013560608401526080850135608084015260a085013591508082111561146057600080fd5b5061146d858286016111d8565b60a0830152505092915050565b80356001600160781b0381168114610f1357600080fd5b600060e082840312156114a357600080fd5b6114ab61101f565b90508135815260208201356020820152604082013560408201526114d160608301610f08565b60608201526114e260808301610f08565b608082015260a08201356001600160401b038082111561150157600080fd5b61150d858386016111d8565b60a084015260c084013591508082111561152657600080fd5b50611533848285016111d8565b60c08301525092915050565b60006060828403121561155157600080fd5b604051606081016001600160401b03828210818311171561157457611574611009565b816040528293508435835260208501356020840152604085013591508082111561159d57600080fd5b506115aa858286016111d8565b6040830152505092915050565b60008060008060008587036101208112156115d157600080fd5b6115da876113c7565b955060208701356001600160401b03808211156115f657600080fd5b6116028a838b016113d8565b965060a0603f198401121561161657600080fd5b61161e611047565b925061162c60408a0161147a565b835261163a60608a0161147a565b60208401526080890135915061ffff8216821461165657600080fd5b81604084015260a0890135915061166c82610ef3565b81606084015260c089013591506bffffffffffffffffffffffff8216821461169357600080fd5b81608084015282955060e08901359250808311156116b057600080fd5b6116bc8a848b01611491565b94506101008901359250808311156116d357600080fd5b50506112608882890161153f565b600082601f8301126116f257600080fd5b81516117006110ce82611099565b81815284602083860101111561171557600080fd5b610cde826020830160208701610e90565b600080600080600080600060e0888a03121561174157600080fd5b875161174c81610ef3565b602089015190975061175d81610ef3565b604089015190965061176e81610ef3565b606089015190955061177f81610ef3565b608089015160a08a015191955093506001600160401b03808211156117a357600080fd5b6117af8b838c016116e1565b935060c08a01519150808211156117c557600080fd5b506117d28a828b016116e1565b91505092959891949750929550565b8082018082111561026457634e487b7160e01b600052601160045260246000fd5b60018060a01b03815116825260208101516020830152604081015160408301526060810151606083015260808101516080830152600060a082015160c060a0850152610cde60c0850182610eb4565b8051825260208101516020830152604081015160408301526000606082015160018060a01b038082166060860152806080850151166080860152505060a082015160e060a08501526118a660e0850182610eb4565b905060c083015184820360c08601526118bf8282610eb4565b95945050505050565b80518252602081015160208301526000604082015160606040850152610cde6060850182610eb4565b600061010080835261190581840188611802565b90506001600160781b038087511660208501528060208801511660408501525061ffff604087015116606084015260018060a01b0360608701511660808401526bffffffffffffffffffffffff60808701511660a084015282810360c084015261196f8186611851565b905082810360e0840152610db681856118c8565b600080600080600060a0868803121561199b57600080fd5b6119a4866113c7565b945060208601356001600160401b03808211156119c057600080fd5b6119cc89838a016113d8565b9550604088013591506119de82610ef3565b9093506060870135906119f082610ef3565b90925060808701359080821115611a0657600080fd5b5061126088828901611491565b608081526000611a266080830187611802565b6001600160a01b038681166020850152851660408401528281036060840152610db68185611851565b600060208284031215611a6157600080fd5b5051919050565b600060208284031215611a7a57600080fd5b81518015158114610e8957600080fd5b60008251611a9c818460208701610e90565b919091019291505056fea2646970667358221220b95d5b14a90e60218b27142c460ed6ab961e9e5555c8da89cc0a7b25d4a3e18d64736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001bcefd8a3067cdb0698993c15f2c62f001fc6222000000000000000000000000db46d1dc155634fbc732f92e853b10b288ad5a1d00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000009446563656e74204f410000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _coreWrapper (address): 0x1bceFD8a3067cDb0698993C15f2c62f001FC6222
Arg [1] : _lensHubProxyContract (address): 0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d
Arg [2] : _metadataURI (string): Decent OA
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000001bcefd8a3067cdb0698993c15f2c62f001fc6222
Arg [1] : 000000000000000000000000db46d1dc155634fbc732f92e853b10b288ad5a1d
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [4] : 446563656e74204f410000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 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.