diff --git a/.DS_Store b/.DS_Store index 21c4d78..d07bff7 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 71f2c6d..96a79b0 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ node_modules # Foundry files /cache_forge -/out \ No newline at end of file +/out +.DS_Store diff --git a/abi/diamondAbi.ts b/abi/diamondAbi.ts new file mode 100644 index 0000000..8be2ae9 --- /dev/null +++ b/abi/diamondAbi.ts @@ -0,0 +1,656 @@ +export const diamondAbi = [ + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "owner_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "AdminFacet__Invalid", + "type": "error" + }, + { + "inputs": [], + "name": "AdminFacet__ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "AccumulatedFeesWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_launchFee", + "type": "uint256" + } + ], + "name": "LaunchFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_liquidity", + "type": "uint256" + } + ], + "name": "MinimumLiquidityETHUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint40", + "name": "_lockDuration", + "type": "uint40" + } + ], + "name": "MinimumLockDurationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_slippage", + "type": "uint256" + } + ], + "name": "SlippageUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_vaporDexAdapter", + "type": "address" + } + ], + "name": "VaporDEXAdapterUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "getLaunchFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "getTokenDetails", + "outputs": [ + { + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tradingStartsAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "getTokenLaunches", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVaporDEXAdapter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_launchFee", + "type": "uint256" + } + ], + "name": "setLaunchFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint40", + "name": "_lockDuration", + "type": "uint40" + } + ], + "name": "setMinLockDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_liquidity", + "type": "uint256" + } + ], + "name": "setMinimumLiquidityETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_slippage", + "type": "uint256" + } + ], + "name": "setSlippage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_vaporDexAdapter", + "type": "address" + } + ], + "name": "setVaporDEXAdapter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "withdrawFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__MinimumLockDuration", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__NotEnoughLiquidity", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + } + ], + "name": "LaunchERC20Facet__TranferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__WrongLaunchArguments", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pair", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_burner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "LiquidityBurned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_pairAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "LiquidityTokensUnlocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_pairAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "LiquidityTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_streamId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_pair", + "type": "address" + } + ], + "name": "StreamCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_creatorAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_streamId", + "type": "uint256" + } + ], + "name": "TokenLaunched", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_tradingStartsAt", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "lockDuration", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "_burnLiquidity", + "type": "bool" + } + ], + "name": "launchERC20", + "outputs": [ + { + "internalType": "address", + "name": "_pair", + "type": "address" + }, + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "authorized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "unAuthorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "LiquidityLockFacet__LiquidityLockedOrDepleted", + "type": "error" + }, + { + "inputs": [], + "name": "LiquidityLockFacet__Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "LiquidityLockFacet__ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "LiquidityTokensUnlocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "LiquidityTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "transferLock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "unlockLiquidityTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] as const; \ No newline at end of file diff --git a/config/index.ts b/config/index.ts index 16adb47..db4268f 100644 --- a/config/index.ts +++ b/config/index.ts @@ -1,56 +1,90 @@ +export const chainNames = ["avalanche", "avalancheFuji"] as const; +export type ChainName = (typeof chainNames)[number]; + +export const chainNameToId = { + avalanche: 43114, + avalancheFuji: 43113, +} as const; + +export type ChainId = (typeof chainNameToId)[ChainName]; + +type AddressMap = { + [key: string]: { + [K in ChainName]: `0x${string}`; + }; +}; + type Config = { [key: string]: { - [chainId: number]: T; + [K in ChainName]: T; }; }; + export const config: Config = { - slippage: { 43_113: BigInt("10000"), 43_114: BigInt("200") }, + slippage: { avalancheFuji: BigInt("10000"), avalanche: BigInt("200") }, minimumNative: { - 43_113: BigInt("1000000000000000"), - 43_114: BigInt("10000000000000000000"), + avalancheFuji: BigInt("1000000000000000"), + avalanche: BigInt("10000000000000000000"), }, launchFeeUSDC: { - 43_113: BigInt("1000000"), - 43_114: BigInt("250000000"), + avalancheFuji: BigInt("1000000"), + avalanche: BigInt("250000000"), + }, + minimumLockDuration: { + avalancheFuji: BigInt("1"), + avalanche: BigInt("90"), }, - minimumLockDuration: { 43_113: BigInt("1"), 43_114: BigInt("90") }, } as const; -export const addresses: Config = { +export const addresses: AddressMap = { teamMultiSig: { - 43_113: "0xCf00c1ac6D26d52054ec89bE6e093F2E270D61d9", - 43_114: "0x6769DB4e3E94A63089f258B9500e0695586315bA", + avalancheFuji: "0xb2a30d5D43DE954b32FacefEa17561c51b7baE9B", + avalanche: "0x6769DB4e3E94A63089f258B9500e0695586315bA", }, vaporDexRouter: { - 43_113: "0x19C0FC4562A4b76F27f86c676eF5a7e38D12a20d", - 43_114: "0x19C0FC4562A4b76F27f86c676eF5a7e38D12a20d", + avalancheFuji: "0x19C0FC4562A4b76F27f86c676eF5a7e38D12a20d", + avalanche: "0x19C0FC4562A4b76F27f86c676eF5a7e38D12a20d", + }, + vaporDexFactory: { + avalancheFuji: "0xC009a670E2B02e21E7e75AE98e254F467f7ae257", + avalanche: "0xC009a670E2B02e21E7e75AE98e254F467f7ae257", }, stratosphereNFT: { - 43_113: "0x65eB37AeB1F2a9cE39556F80044607dD969b0336", - 43_114: "0x08e287adCf9BF6773a87e1a278aa9042BEF44b60", + avalancheFuji: "0x65eB37AeB1F2a9cE39556F80044607dD969b0336", + avalanche: "0x08e287adCf9BF6773a87e1a278aa9042BEF44b60", }, vaporDexAggregatorRouter: { - 43_113: "0x55477d8537ede381784b448876AfAa98aa450E63", - 43_114: "0x55477d8537ede381784b448876AfAa98aa450E63", + avalancheFuji: "0x55477d8537ede381784b448876AfAa98aa450E63", + avalanche: "0x55477d8537ede381784b448876AfAa98aa450E63", }, vaporDexAggregatorAdapter: { - 43_113: "0x3F1aF4D92c91511A0BCe4B21bc256bF63bcab470", - 43_114: "0x01e5C45cB25E30860c2Fb80369A9C27628911a2b", + avalancheFuji: "0x3F1aF4D92c91511A0BCe4B21bc256bF63bcab470", + avalanche: "0x01e5C45cB25E30860c2Fb80369A9C27628911a2b", }, usdc: { - 43_113: "0xeA42E3030ab1406a0b6aAd077Caa927673a2c302", - 43_114: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", + avalancheFuji: "0xeA42E3030ab1406a0b6aAd077Caa927673a2c302", + avalanche: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", }, vape: { - 43_113: "0x3bD01B76BB969ef2D5103b5Ea84909AD8d345663", - 43_114: "0x7bddaF6DbAB30224AA2116c4291521C7a60D5f55", + avalancheFuji: "0x3bD01B76BB969ef2D5103b5Ea84909AD8d345663", + avalanche: "0x7bddaF6DbAB30224AA2116c4291521C7a60D5f55", + }, + weth: { + avalancheFuji: "0xd00ae08403B9bbb9124bB305C09058E32C39A48c", + avalanche: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7", }, sablier: { - 43_113: "0xebf7ed508a0Bb1c4e66b9E6F8C6a73342E7049ac", - 43_114: "0xB24B65E015620455bB41deAAd4e1902f1Be9805f", + avalancheFuji: "0xebf7ed508a0Bb1c4e66b9E6F8C6a73342E7049ac", + avalanche: "0xB24B65E015620455bB41deAAd4e1902f1Be9805f", }, nonFungiblePositionManager: { - 43_113: "0x7a0A7C4273B25b3a71Daeaa387c7855081AC4E56", - 43_114: "0xC967b23826DdAB00d9AAd3702CbF5261B7Ed9a3a", + avalancheFuji: "0x7a0A7C4273B25b3a71Daeaa387c7855081AC4E56", + avalanche: "0xC967b23826DdAB00d9AAd3702CbF5261B7Ed9a3a", + }, + create3Factory: { + avalancheFuji: "0x8f3b1d04C01621553ee04A7B118844c356307f14", + avalanche: "0x8f3b1d04C01621553ee04A7B118844c356307f14", }, } as const; + +export const BURN_WALLET = "0x000000000000000000000000000000000000dEaD"; diff --git a/contracts/TokenFactory.sol b/contracts/TokenFactory.sol.old similarity index 99% rename from contracts/TokenFactory.sol rename to contracts/TokenFactory.sol.old index daa3a1a..e81a65f 100644 --- a/contracts/TokenFactory.sol +++ b/contracts/TokenFactory.sol.old @@ -5,7 +5,7 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IVaporDEXFactory} from "./interfaces/IVaporDEXFactory.sol"; import {IVaporDEXRouter} from "./interfaces/IVaporDEXRouter.sol"; -import {Token} from "./Token.sol"; +import {ERC20Token} from "./tokens/ERC20Token.sol"; import {ISablierV2LockupLinear} from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; import {LockupLinear} from "@sablier/v2-core/src/types/DataTypes.sol"; import {IDexAggregator} from "./interfaces/IDexAggregator.sol"; diff --git a/contracts/TokenFactoryDiamond.sol b/contracts/TokenFactoryDiamond.sol new file mode 100644 index 0000000..dbecdc2 --- /dev/null +++ b/contracts/TokenFactoryDiamond.sol @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {IDiamondCut} from "./interfaces/IDiamondCut.sol"; +import {LibDiamond} from "./libraries/LibDiamond.sol"; + +error TokenFactoryDiamond__InvalidFunction(); + +contract TokenFactoryDiamond { + constructor(address _owner, address _diamondCutFacet) payable { + LibDiamond.updateContractOwner(_owner); + + IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1); + + bytes4[] memory functionSelectors = new bytes4[](1); + + functionSelectors[0] = IDiamondCut.diamondCut.selector; + cut[0] = IDiamondCut.FacetCut({ + facetAddress: _diamondCutFacet, + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: functionSelectors + }); + + LibDiamond.diamondCut(cut, address(0), ""); + } + + fallback() external payable { + LibDiamond.DiamondStorage storage ds; + + bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION; + + assembly { + ds.slot := position + } + + address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress; + + if (facet == address(0)) revert TokenFactoryDiamond__InvalidFunction(); + + assembly { + calldatacopy(0, 0, calldatasize()) + + let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0) + + returndatacopy(0, 0, returndatasize()) + + switch result + case 0 { + revert(0, returndatasize()) + } + default { + return(0, returndatasize()) + } + } + } + + // Fallback + receive() external payable {} +} diff --git a/contracts/facets/AdminFacet.sol b/contracts/facets/AdminFacet.sol new file mode 100644 index 0000000..923a8bb --- /dev/null +++ b/contracts/facets/AdminFacet.sol @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.22; + +import {AppStorage, Modifiers} from "../libraries/LibAppStorage.sol"; +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {IERC20Token} from "../interfaces/IERC20Token.sol"; + +error AdminFacet__Invalid(); +error AdminFacet__ZeroAddress(); +error AdminFacet__InsufficientBalance(); + +contract AdminFacet is Modifiers { + event MinimumLiquidityETHUpdated(uint256 _liquidity); + event SlippageUpdated(uint256 _slippage); + event MinimumLockDurationUpdated(uint40 _lockDuration); + event LaunchFeeUpdated(uint256 _launchFee); + event VaporDEXAdapterUpdated(address _vaporDexAdapter); + event EmergencyWithdraw(address indexed _token, uint256 indexed _balance, address _to); + + /** + * @dev Sets the minimum liquidity for creating new tokens. + * @param _liquidity New liquidity. + */ + + function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner { + if (_liquidity == 0) { + revert AdminFacet__Invalid(); + } + s.minLiquidityETH = _liquidity; + emit MinimumLiquidityETHUpdated(_liquidity); + } + + /** + * @dev Sets the minimum liquidity for creating new tokens. + * @param _slippage New lock duration in days. + */ + + function setSlippage(uint256 _slippage) external onlyOwner { + s.slippage = _slippage; + emit SlippageUpdated(_slippage); + } + + /** + * @dev Sets the minimum liquidity for creating new tokens. + * @param _lockDuration New lock duration in days. + */ + + function setMinLockDuration(uint40 _lockDuration) external onlyOwner { + if (_lockDuration == 0) { + revert AdminFacet__Invalid(); + } + s.minLockDuration = _lockDuration; + emit MinimumLockDurationUpdated(_lockDuration); + } + + /** + * @dev Sets the launch fee for creating new tokens. + * @param _launchFee New launch fee in USDC. + */ + + function setLaunchFee(uint256 _launchFee) external onlyOwner { + if (_launchFee == 0) { + revert AdminFacet__Invalid(); + } + s.launchFee = _launchFee; + emit LaunchFeeUpdated(_launchFee); + } + + /** + * @dev Sets the VaporDEX adapter address. + * @param _vaporDexAdapter New VaporDEX adapter address. + */ + + function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner { + if ( + _vaporDexAdapter == s.vaporDEXAdapter || + _vaporDexAdapter == address(0) + ) { + revert AdminFacet__Invalid(); + } + s.vaporDEXAdapter = _vaporDexAdapter; + emit VaporDEXAdapterUpdated(_vaporDexAdapter); + } + + /** + * @dev Withdraws any stuck tokens (LP Or USDC) to the specified address. + * @param _token Address of the token to be withdrawn. + * @param _to Address to which the tokens are withdrawn. + */ + + function emergencyWithdraw(address _token, address _to) external onlyOwner { + if (_to == address(0) || _token == address(0)) { + revert AdminFacet__ZeroAddress(); + } + IERC20 token = IERC20(_token); + uint256 balance = token.balanceOf(address(this)); + if (balance == 0) { + revert AdminFacet__InsufficientBalance(); + } + token.transfer(_to, balance); + emit EmergencyWithdraw(_token, balance, _to); + } + + /** + * @dev Retrieves the token launch information for a given owner. + * @param _owner The address of the owner. + * @return An array of token addresses associated with the owner. + */ + function getTokenLaunches( + address _owner + ) external view returns (address[] memory) { + return s.userToTokens[_owner]; + } + + /** + * @dev Retrieves the details of a token. + * @param _token The address of the token. + * @return deployer The address of the token's deployer. + * @return tokenAddress The address of the token. + * @return liquidityPool The address of the token's liquidity pool. + * @return tradingStartsAt The timestamp when trading starts for the token. + * @return streamId The stream ID associated with the token's liquidity lock. Returns 0 if burned. + */ + function getTokenDetails( + address _token + ) + public + view + returns ( + address deployer, + address tokenAddress, + address liquidityPool, + uint256 tradingStartsAt, + uint256 streamId + ) + { + IERC20Token token = IERC20Token(_token); + deployer = token.deployer(); + tokenAddress = address(token); + liquidityPool = token.liquidityPool(); + tradingStartsAt = token.tradingStartsAt(); + streamId = s.liquidityLocks[deployer][tokenAddress]; + } + + function getLaunchFee() external view returns (uint256) { + return s.launchFee; + } + + function getVaporDEXAdapter() external view returns (address) { + return s.vaporDEXAdapter; + } +} diff --git a/contracts/facets/AuthorizationFacet.sol b/contracts/facets/AuthorizationFacet.sol new file mode 100644 index 0000000..a1defca --- /dev/null +++ b/contracts/facets/AuthorizationFacet.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {LibDiamond} from "../libraries/LibDiamond.sol"; + +import {AppStorage} from "../libraries/LibAppStorage.sol"; +import {LibAuthorizable} from "../libraries/LibAuthorizable.sol"; + +/// @title AuthorizationFacet +/// @notice Facet in charge of displaying and setting the authorization variables +/// @dev Utilizes 'LDiamond', 'AppStorage' and 'LibAuthorizable' +contract AuthorizationFacet { + AppStorage s; + + /// @notice Get if address is authorized + /// @param _address Address + function authorized(address _address) external view returns (bool) { + return s.authorized[_address]; + } + + /// @notice Authorize address + /// @param _address Address to authorize + function authorize(address _address) external { + LibDiamond.enforceIsOwner(); + + s.authorized[_address] = true; + } + + /// @notice Un-authorize address + /// @param _address Address to un-authorize + function unAuthorize(address _address) external { + LibDiamond.enforceIsOwner(); + + s.authorized[_address] = false; + } +} diff --git a/contracts/facets/DiamondCutFacet.sol b/contracts/facets/DiamondCutFacet.sol new file mode 100644 index 0000000..fac5e62 --- /dev/null +++ b/contracts/facets/DiamondCutFacet.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {IDiamondCut} from "../interfaces/IDiamondCut.sol"; +import {LibDiamond} from "../libraries/LibDiamond.sol"; + +/// @title DiamondCutFacet +/// @author Modified from Nick Mudge: https://github.com/mudgen/diamond-3-hardhat +/// @notice Facet in charge of the diamond cut +/// @dev Utilizes 'IDiamondCut' and 'LDiamond' +contract DiamondCutFacet is IDiamondCut { + /// @notice Diamond cut + /// @param _cut Facet cut + /// @param _init Address of the initialization contract + /// @param _data Data + function diamondCut( + FacetCut[] calldata _cut, + address _init, + bytes calldata _data + ) external { + LibDiamond.enforceIsOwner(); + LibDiamond.diamondCut(_cut, _init, _data); + } +} diff --git a/contracts/facets/DiamondLoupeFacet.sol b/contracts/facets/DiamondLoupeFacet.sol new file mode 100644 index 0000000..9439d61 --- /dev/null +++ b/contracts/facets/DiamondLoupeFacet.sol @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {IDiamondLoupe} from "../interfaces/IDiamondLoupe.sol"; +import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol"; +import {LibDiamond} from "../libraries/LibDiamond.sol"; + +/// @title DiamondLoupeFacet +/// @author Modified from Nick Mudge: https://github.com/mudgen/diamond-3-hardhat +/// @notice Facet in charge of the diamond loupe +/// @dev Utilizes 'IDiamondLoupe', 'IERC165' and 'LDiamond' +contract DiamondLoupeFacet is IDiamondLoupe, IERC165 { + /// @notice Get all the facets within the diamond + function facets() external view returns (Facet[] memory facets_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + + uint256 numFacets = ds.facetAddresses.length; + + facets_ = new Facet[](numFacets); + + for (uint256 i; i < numFacets; ++i) { + address facetAddress_ = ds.facetAddresses[i]; + + facets_[i].facetAddress = facetAddress_; + facets_[i].functionSelectors = ds + .facetFunctionSelectors[facetAddress_] + .functionSelectors; + } + } + + /// @notice Get facet function selectors + /// @param _facet Address of the facet + function facetFunctionSelectors( + address _facet + ) external view returns (bytes4[] memory facetFunctionSelectors_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + + facetFunctionSelectors_ = ds + .facetFunctionSelectors[_facet] + .functionSelectors; + } + + /// @notice Get addresses of facets + function facetAddresses() + external + view + returns (address[] memory facetAddresses_) + { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + + facetAddresses_ = ds.facetAddresses; + } + + /// @notice Get facet address of function selector + /// @param _functionSelector Function selector + function facetAddress( + bytes4 _functionSelector + ) external view returns (address facetAddress_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + + facetAddress_ = ds + .selectorToFacetAndPosition[_functionSelector] + .facetAddress; + } + + /// @notice Get if contract supports interface + /// @param _id Interface ID + function supportsInterface(bytes4 _id) external view returns (bool) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + + return ds.supportedInterfaces[_id]; + } +} diff --git a/contracts/facets/LaunchERC20Facet.sol b/contracts/facets/LaunchERC20Facet.sol new file mode 100644 index 0000000..e6a5e8a --- /dev/null +++ b/contracts/facets/LaunchERC20Facet.sol @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.22; + +import {ILaunchERC20Facet} from "../interfaces/ILaunchERC20Facet.sol"; +import {AppStorage} from "../libraries/LibAppStorage.sol"; +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {IVaporDEXFactory} from "../interfaces/IVaporDEXFactory.sol"; +import {IVaporDEXRouter} from "../interfaces/IVaporDEXRouter.sol"; +import {ISablierV2LockupLinear} from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; +import {LockupLinear} from "@sablier/v2-core/src/types/DataTypes.sol"; +import {IERC20Token} from "../interfaces/IERC20Token.sol"; +import {IDexAggregator} from "../interfaces/IDexAggregator.sol"; +import {INonfungiblePositionManager} from "../interfaces/INonfungiblePositionManager.sol"; +import {LibPercentages} from "../libraries/LibPercentages.sol"; +import {ERC20Token} from "../tokens/ERC20Token.sol"; + +error LaunchERC20Facet__NotEnoughLiquidity(); +error LaunchERC20Facet__InsufficientBalance(); +error LaunchERC20Facet__TranferFailed(address _from); +error LaunchERC20Facet__ZeroAddress(); +error LaunchERC20Facet__MinimumLockDuration(); +error LaunchERC20Facet__WrongLaunchArguments(); + +contract LaunchERC20Facet is ILaunchERC20Facet { + AppStorage s; + + function launchERC20( + string memory _name, + string memory _symbol, + uint256 _totalSupply, + uint256 _tradingStartsAt, + uint40 lockDuration, + bool _burnLiquidity + ) + external + payable + returns (address _pair, address _tokenAddress, uint256 streamId) + { + if (msg.value < s.minLiquidityETH) { + revert LaunchERC20Facet__NotEnoughLiquidity(); + } + + // Step 0: Transfer Fee + _transferLaunchFee(msg.sender); + + // Step 1: Create the token + _tokenAddress = _createToken( + _name, + _symbol, + _totalSupply, + _tradingStartsAt, + s.vaporDEXAggregator, + s.vaporDEXAdapter + ); + IERC20Token _token = IERC20Token(_tokenAddress); + + // Step 2: Create the pair + IVaporDEXFactory _factory = IVaporDEXFactory(s.vaporDEXFactory); + _pair = _factory.createPair(_tokenAddress, address(s.WETH)); + _token.approve(s.vaporDEXRouter, _totalSupply); + _token.approve(_pair, _totalSupply); + + // Step 3: Add Liquidity + IVaporDEXRouter _router = IVaporDEXRouter(s.vaporDEXRouter); + _router.addLiquidityETH{value: msg.value}( + _tokenAddress, + _totalSupply, + _totalSupply, + msg.value, + address(this), + block.timestamp + 10 minutes + ); + + // Step 4: Get the pair address + _pair = _factory.getPair(_tokenAddress, address(s.WETH)); + if (_pair == address(0)) { + revert LaunchERC20Facet__ZeroAddress(); + } + + // Step 5: Set the LP address in the token + _token.setLiquidityPool(_pair); + // Step 6: Renounce ownership of the token + _token.renounceOwnership(); + + // Step 6: Lock Or Burn Liquidity + IERC20 _lpToken = IERC20(_pair); + + if (_burnLiquidity) { + // Burn Liquidity + _lpToken.transfer(address(0), _lpToken.balanceOf(address(this))); + emit LiquidityBurned( + _pair, + msg.sender, + _lpToken.balanceOf(address(this)) + ); + } else { + if (lockDuration < s.minLockDuration) { + revert LaunchERC20Facet__MinimumLockDuration(); + } + _lpToken.approve( + address(s.sablier), + _lpToken.balanceOf(address(this)) + ); + // Lock Liquidity + // SablierV2 + LockupLinear.CreateWithDurations memory params; + + // Declare the function parameters + params.sender = address(this); // The sender will be able to cancel the stream + params.recipient = msg.sender; // The recipient of the streamed assets + params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees + params.asset = _lpToken; // The streaming asset + params.cancelable = false; // Whether the stream will be cancelable or not + params.transferable = true; // Whether the stream will be transferrable or not + params.durations = LockupLinear.Durations({ + cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period + total: lockDuration * 1 days + }); + + // Create the stream + streamId = ISablierV2LockupLinear(s.sablier).createWithDurations( + params + ); + s.liquidityLocks[msg.sender][_tokenAddress] = streamId; + + emit StreamCreated(streamId, msg.sender, _pair); + } + + // Step 7: Buy VAPE with USDC on VaporDEXAggregator + _buyVapeWithUsdc(s.launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee + + // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2 + _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract + + // Step 9: Store the token launch for FETCHING + s.userToTokens[msg.sender].push(_tokenAddress); + emit TokenLaunched(_tokenAddress, msg.sender, streamId); + } + + /** + * @dev Creates a new Token contract with specified parameters. + * @param name Name of the token. + * @param symbol Symbol of the token. + * @param totalSupply Total supply of the token. + * @param _tradingStartsAt Timestamp when trading starts for the token. + * @param dexAggregator Address of the decentralized exchange aggregator. + * @param dexAdapter Address of the decentralized exchange adapter. + * @return _token Instance of the created Token contract. + */ + function _createToken( + string memory name, + string memory symbol, + uint256 totalSupply, + uint256 _tradingStartsAt, + address dexAggregator, + address dexAdapter + ) internal returns (address _token) { + if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) { + revert LaunchERC20Facet__WrongLaunchArguments(); + } + _token = address( + new ERC20Token( + name, + symbol, + totalSupply, + s.stratosphere, + address(this), + _tradingStartsAt, + dexAggregator, + dexAdapter, + msg.sender + ) + ); + } + + /** + * @dev Transfers the launch fee in USDC from the sender. + * @param _from Address from which the launch fee is transferred. + */ + + function _transferLaunchFee(address _from) internal { + IERC20 _usdc = IERC20(s.USDC); + if (_usdc.balanceOf(_from) < s.launchFee) { + revert LaunchERC20Facet__InsufficientBalance(); + } + bool isSuccess = _usdc.transferFrom(_from, address(this), s.launchFee); + if (!isSuccess) { + revert LaunchERC20Facet__TranferFailed(_from); + } + } + + /** + * @dev Buys VAPE with USDC on VaporDEXAggregator + * @param amountIn Amount of USDC to be used for buying VAPE. + */ + + function _buyVapeWithUsdc(uint256 amountIn) internal { + IERC20(s.USDC).approve(address(s.vaporDEXAggregator), amountIn); + + IDexAggregator.FormattedOffer memory offer = IDexAggregator( + s.vaporDEXAggregator + ).findBestPath( + amountIn, + address(s.USDC), + address(s.VAPE), + 1 // can be changed to 3 + ); + IDexAggregator.Trade memory trade; + trade.amountIn = amountIn; + trade.amountOut = offer.amounts[offer.amounts.length - 1]; + trade.path = offer.path; + trade.adapters = offer.adapters; + IDexAggregator(s.vaporDEXAggregator).swapNoSplit( + trade, + address(this), + 0 + ); + } + + /** + * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2. + * @notice Uses the balance of VAPE and USDC in the contract. + */ + + function _addLiquidityVapeUsdc() internal { + address _usdc = s.USDC; + address _vape = s.VAPE; + uint256 amountInUSDC = IERC20(_usdc).balanceOf(address(this)); + uint256 amountInVAPE = IERC20(_vape).balanceOf(address(this)); + IERC20(_usdc).approve( + address(s.nonFungiblePositionManager), + amountInUSDC + ); + IERC20(_vape).approve( + address(s.nonFungiblePositionManager), + amountInVAPE + ); + INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager + .MintParams({ + token0: _vape, + token1: _usdc, + fee: 3000, + tickLower: -887220, // full range + tickUpper: 887220, // full range + amount0Desired: amountInVAPE, + amount1Desired: amountInUSDC, + amount0Min: amountInVAPE - + LibPercentages.percentage(amountInVAPE, s.slippage), // 2% slippage + amount1Min: amountInUSDC - + LibPercentages.percentage(amountInUSDC, s.slippage), // 2% slippage + recipient: s.teamMultisig, + deadline: block.timestamp + 2 minutes + }); + INonfungiblePositionManager(s.nonFungiblePositionManager).mint( + mintParams + ); + + // Q: What checks should be done with the return values? + } +} diff --git a/contracts/facets/LiquidityLockFacet.sol b/contracts/facets/LiquidityLockFacet.sol new file mode 100644 index 0000000..61e5072 --- /dev/null +++ b/contracts/facets/LiquidityLockFacet.sol @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.22; + +import {AppStorage} from "../libraries/LibAppStorage.sol"; +import {ISablierV2LockupLinear} from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; + +error LiquidityLockFacet__Unauthorized(); +error LiquidityLockFacet__ZeroAddress(); +error LiquidityLockFacet__LiquidityLockedOrDepleted(); + +contract LiquidityLockFacet { + AppStorage internal s; + + event LiquidityTokensUnlocked(address _tokenAddress, address _receiver); + event LiquidityTransferred(address _tokenAddress, address _to); + + /** + * @dev Unlocks liquidity tokens for the specified pair and recipient. + * @param _tokenAddress Address of the token pair. + * @param _receiver Address of the recipient of unlocked tokens. + * @notice It is recommended to direct the user to Sablier UI for better error handling. + */ + function unlockLiquidityTokens( + address _tokenAddress, + address _receiver + ) external { + if (_receiver == address(0)) { + revert LiquidityLockFacet__ZeroAddress(); + } + uint256 streamId = s.liquidityLocks[msg.sender][_tokenAddress]; + + if (streamId == 0) { + revert LiquidityLockFacet__Unauthorized(); + } + ISablierV2LockupLinear sablier = ISablierV2LockupLinear(s.sablier); + + uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId); + if (withdrawableAmount == 0) { + revert LiquidityLockFacet__LiquidityLockedOrDepleted(); + } + + sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier + + emit LiquidityTokensUnlocked(_tokenAddress, _receiver); + } + + /** + * @dev Transfers the locked liquidity to the specified recipient for the given token. + * @param _tokenAddress Address of the token. + * @param _to Address of the recipient. + */ + function transferLock(address _tokenAddress, address _to) external { + uint256 streamId = s.liquidityLocks[msg.sender][_tokenAddress]; + ISablierV2LockupLinear sablier = ISablierV2LockupLinear(s.sablier); + if ( + streamId == 0 || + _to == address(0) || + sablier.isTransferable(streamId) == false + ) { + revert LiquidityLockFacet__Unauthorized(); + } + + s.liquidityLocks[_to][_tokenAddress] = streamId; + s.liquidityLocks[msg.sender][_tokenAddress] = 0; + + sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier + + emit LiquidityTransferred(_tokenAddress, _to); + } +} diff --git a/contracts/facets/OwnershipFacet.sol b/contracts/facets/OwnershipFacet.sol new file mode 100644 index 0000000..f2639d9 --- /dev/null +++ b/contracts/facets/OwnershipFacet.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {LibDiamond} from "../libraries/LibDiamond.sol"; +import {IERC173} from "../interfaces/IERC173.sol"; + +/// @title OwnershipFacet +/// @author Modified from Nick Mudge: https://github.com/mudgen/diamond-3-hardhat +/// @notice Facet in charge of administrating the ownership of the contract +/// @notice Utilizes 'IERC173' and 'LDiamond' +contract OwnershipFacet is IERC173 { + /// @notice Get contract owner + function owner() external view returns (address owner_) { + owner_ = LibDiamond.contractOwner(); + } + + /// @notice Transfer ownership + /// @param _owner New owner + function transferOwnership(address _owner) external { + LibDiamond.enforceIsOwner(); + LibDiamond.updateContractOwner(_owner); + } +} diff --git a/contracts/interfaces/IDiamondCut.sol b/contracts/interfaces/IDiamondCut.sol new file mode 100644 index 0000000..f5d9329 --- /dev/null +++ b/contracts/interfaces/IDiamondCut.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +/******************************************************************************/ + +interface IDiamondCut { + enum FacetCutAction { + Add, + Replace, + Remove + } + + struct FacetCut { + address facetAddress; + FacetCutAction action; + bytes4[] functionSelectors; + } + + /// @notice Add/replace/remove any number of functions and optionally execute + /// a function with delegatecall + /// @param _diamondCut Contains the facet addresses and function selectors + /// @param _init The address of the contract or facet to execute _calldata + /// @param _calldata A function call, including function selector and arguments + /// _calldata is executed with delegatecall on _init + function diamondCut( + FacetCut[] calldata _diamondCut, + address _init, + bytes calldata _calldata + ) external; + + event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); +} diff --git a/contracts/interfaces/IDiamondLoupe.sol b/contracts/interfaces/IDiamondLoupe.sol new file mode 100644 index 0000000..09f1103 --- /dev/null +++ b/contracts/interfaces/IDiamondLoupe.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/// @title IDiamondLoupe +/// @author Modified from Nick Mudge: https://github.com/mudgen/diamond-3-hardhat +/// @dev EIP-2535 "Diamond" standard +interface IDiamondLoupe { + /////////////// + /// STORAGE /// + /////////////// + + struct Facet { + address facetAddress; + bytes4[] functionSelectors; + } + + ///////////// + /// LOGIC /// + ///////////// + + function facetAddress( + bytes4 selector + ) external view returns (address facetAddress); + + function facetAddresses() + external + view + returns (address[] memory facetAddresses); + + function facetFunctionSelectors( + address facet + ) external view returns (bytes4[] memory facetFunctionSelectors); + + function facets() external view returns (Facet[] memory facets); +} diff --git a/contracts/interfaces/IERC173.sol b/contracts/interfaces/IERC173.sol new file mode 100644 index 0000000..9040510 --- /dev/null +++ b/contracts/interfaces/IERC173.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/// @title ERC-173 Contract Ownership Standard +/// Note: the ERC-165 identifier for this interface is 0x7f5828d0 +/* is ERC165 */ +interface IERC173 { + /// @notice Get the address of the owner + /// @return owner_ The address of the owner. + function owner() external view returns (address owner_); + + /// @notice Set the address of the new owner of the contract + /// @dev Set _newOwner to address(0) to renounce any ownership. + /// @param _newOwner The address of the new owner of the contract + function transferOwnership(address _newOwner) external; +} diff --git a/contracts/interfaces/IERC20Token.sol b/contracts/interfaces/IERC20Token.sol new file mode 100644 index 0000000..f1ec497 --- /dev/null +++ b/contracts/interfaces/IERC20Token.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.22; + +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +interface IERC20Token is IERC20 { + function setLiquidityPool(address _pool) external; + + function renounceOwnership() external; + + function deployer() external view returns (address); + + function liquidityPool() external view returns (address); + + function tradingStartsAt() external view returns (uint256); +} diff --git a/contracts/interfaces/ILaunchERC20Facet.sol b/contracts/interfaces/ILaunchERC20Facet.sol new file mode 100644 index 0000000..73ee492 --- /dev/null +++ b/contracts/interfaces/ILaunchERC20Facet.sol @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.22; + +interface ILaunchERC20Facet { + ////////////// + /// EVENTS /// + ////////////// + + event TokenLaunched( + address indexed _tokenAddress, + address indexed _creatorAddress, + uint256 indexed _streamId + ); + + event StreamCreated( + uint256 indexed _streamId, + address indexed _sender, + address indexed _pair + ); + event LiquidityBurned( + address indexed pair, + address indexed _burner, + uint256 _amount + ); + event LiquidityTokensUnlocked( + address indexed _pairAddress, + address indexed _receiver + ); + event LiquidityTransferred( + address indexed _pairAddress, + address indexed _to + ); + + function launchERC20( + string memory _name, + string memory _symbol, + uint256 _totalSupply, + uint256 _tradingStartsAt, + uint40 lockDuration, + bool _burnLiquidity + ) + external + payable + returns (address _pair, address _tokenAddress, uint256 streamId); +} diff --git a/contracts/libraries/LibAppStorage.sol b/contracts/libraries/LibAppStorage.sol new file mode 100644 index 0000000..1944685 --- /dev/null +++ b/contracts/libraries/LibAppStorage.sol @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {LibDiamond} from "../libraries/LibDiamond.sol"; +import {LibAuthorizable} from "./LibAuthorizable.sol"; + +struct AppStorage { + ///////////////////// + /// AUTHORIZATION /// + ///////////////////// + mapping(address => bool) authorized; + //////////////////////// + /// ERC20LaunchFacet /// + //////////////////////// + address vaporDEXFactory; + address vaporDEXRouter; + address stratosphere; + address vaporDEXAggregator; + address vaporDEXAdapter; + address USDC; + address VAPE; + address WETH; + address sablier; + address nonFungiblePositionManager; + address teamMultisig; + uint256 launchFee; + uint256 minLiquidityETH; + uint256 slippage; + uint256 tokenLaunchesCount; + uint40 minLockDuration; + mapping(address => address[]) userToTokens; + mapping(address => mapping(address => uint256)) liquidityLocks; + /////////////////////////////// + /// BondingCurveLaunchFacet /// + /////////////////////////////// +} + +library LibAppStorage { + function diamondStorage() internal pure returns (AppStorage storage ds) { + assembly { + ds.slot := 0 + } + } +} + +contract Modifiers { + AppStorage internal s; + + modifier onlyAuthorized() { + require(s.authorized[msg.sender], "Not authorized"); + _; + } + + modifier onlyOwner() { + LibDiamond.enforceIsOwner(); + _; + } + + modifier onlyValidAddress(address _address) { + require(_address != address(0), "Invalid address"); + _; + } +} diff --git a/contracts/libraries/LibAuthorizable.sol b/contracts/libraries/LibAuthorizable.sol new file mode 100644 index 0000000..79073c5 --- /dev/null +++ b/contracts/libraries/LibAuthorizable.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {AppStorage} from "./LibAppStorage.sol"; + +error LibAuthorizable__OnlyAuthorized(); + +/// @title LibAuthorizable +library LibAuthorizable { + ///////////// + /// LOGIC /// + ///////////// + + /// @notice Enforce only authorized address can call a certain function + /// @param s AppStorage + /// @param _address Address + function enforceIsAuthorized( + AppStorage storage s, + address _address + ) internal view { + if (!s.authorized[_address]) revert LibAuthorizable__OnlyAuthorized(); + } +} diff --git a/contracts/libraries/LibDiamond.sol b/contracts/libraries/LibDiamond.sol new file mode 100644 index 0000000..35505e6 --- /dev/null +++ b/contracts/libraries/LibDiamond.sol @@ -0,0 +1,394 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import "../interfaces/IDiamondCut.sol"; + +error LibDiamond__AddressMustBeZero(); +error LibDiamond__FunctionAlreadyExists(); +error LibDiamond__ImmutableFunction(); +error LibDiamond__IncorrectAction(); +error LibDiamond__InexistentFacetCode(); +error LibDiamond__InexistentFunction(); +error LibDiamond__InitializationFailed(address init, bytes data); +error LibDiamond__InvalidAddressZero(); +error LibDiamond__InvalidReplacementWithSameFunction(); +error LibDiamond__NoSelectors(); +error LibDiamond__OnlyOwner(address owner, address sender); + +/// @title LibDiamond +/// @author Modified from Nick Mudge: https://github.com/mudgen/diamond-3-hardhat +/// @notice Diamond library +/// @dev EIP-2535 "Diamond" standard +library LibDiamond { + ////////////// + /// EVENTS /// + ////////////// + + event DiamondCut(IDiamondCut.FacetCut[] _cut, address _init, bytes _data); + + event OwnershipTransferred( + address indexed oldOwner, + address indexed newOwner + ); + + /////////////// + /// STORAGE /// + /////////////// + + bytes32 constant DIAMOND_STORAGE_POSITION = + keccak256("diamond.standard.diamond.storage"); + + struct FacetAddressAndPosition { + /// @notice Address of the facet + address facetAddress; + /// @notice Position of the facet in `facetFunctionSelectors.functionSelectors` array + uint96 functionSelectorPosition; + } + + struct FacetFunctionSelectors { + /// @notice Selectors of functions + bytes4[] functionSelectors; + /// @notice Position of `facetAddress` in `facetAddresses` array + uint256 facetAddressPosition; + } + + struct DiamondStorage { + /// @notice Position of selector in `facetFunctionSelectors.selectors` array + mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition; + /// @notice Addresses of the facets to selectors of the functions + mapping(address => FacetFunctionSelectors) facetFunctionSelectors; + /// @notice Facet addresses + address[] facetAddresses; + /// @notice Query if contract implements an interface + mapping(bytes4 => bool) supportedInterfaces; + /// @notice Owner of the contract + address owner; + } + + ///////////// + /// LOGIC /// + ///////////// + + /// @notice Set the storage of the diamond + function diamondStorage() + internal + pure + returns (DiamondStorage storage ds) + { + bytes32 position = DIAMOND_STORAGE_POSITION; + + /// @solidity memory-safe-assembly + assembly { + ds.slot := position + } + } + + /// @notice Update the owner of the diamond + /// @param _owner New owner + function updateContractOwner(address _owner) internal { + DiamondStorage storage ds = diamondStorage(); + + address oldOwner = ds.owner; + + ds.owner = _owner; + + emit OwnershipTransferred(oldOwner, _owner); + } + + /// @notice Get the owner of the diamond + function contractOwner() internal view returns (address owner_) { + owner_ = diamondStorage().owner; + } + + /// @notice Enforce is the owner of the diamond + function enforceIsOwner() internal view { + if (diamondStorage().owner != msg.sender) + revert LibDiamond__OnlyOwner(diamondStorage().owner, msg.sender); + } + + /// @notice Perform a diamond cut + /// @param _cut Diamond cut + /// @param _init Address of the initialization contract + /// @param _data Data + function diamondCut( + IDiamondCut.FacetCut[] memory _cut, + address _init, + bytes memory _data + ) internal { + for (uint256 facetIndex; facetIndex < _cut.length; ) { + IDiamondCut.FacetCutAction action = _cut[facetIndex].action; + + if (action == IDiamondCut.FacetCutAction.Add) { + addFunctions( + _cut[facetIndex].facetAddress, + _cut[facetIndex].functionSelectors + ); + } else if (action == IDiamondCut.FacetCutAction.Replace) { + replaceFunctions( + _cut[facetIndex].facetAddress, + _cut[facetIndex].functionSelectors + ); + } else if (action == IDiamondCut.FacetCutAction.Remove) { + removeFunctions( + _cut[facetIndex].facetAddress, + _cut[facetIndex].functionSelectors + ); + } else { + revert LibDiamond__IncorrectAction(); + } + /// @notice Realistically impossible to overflow/underflow + unchecked { + ++facetIndex; + } + } + + emit DiamondCut(_cut, _init, _data); + + initializeDiamondCut(_init, _data); + } + + /// @notice Add functions to the diamond + /// @param _facet Address of the facet + /// @param _selectors Selectors of the facet + function addFunctions(address _facet, bytes4[] memory _selectors) internal { + if (_selectors.length == 0) revert LibDiamond__NoSelectors(); + + DiamondStorage storage ds = diamondStorage(); + + if (_facet == address(0)) revert LibDiamond__InvalidAddressZero(); + + uint96 selectorPosition = uint96( + ds.facetFunctionSelectors[_facet].functionSelectors.length + ); + + /// @notice Add a new facet address if it does not exists already + + if (selectorPosition == 0) addFacet(ds, _facet); + + for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { + bytes4 selector = _selectors[selectorIndex]; + + address oldFacetAddress = ds + .selectorToFacetAndPosition[selector] + .facetAddress; + + if (oldFacetAddress != address(0)) + revert LibDiamond__FunctionAlreadyExists(); + + addFunction(ds, selector, selectorPosition, _facet); + + /// @notice Realistically impossible to overflow/underflow + unchecked { + ++selectorIndex; + ++selectorPosition; + } + } + } + + /// @notice Replace functions inside the diamond + /// @param _facet Address of the facet + /// @param _selectors Selectors of the facet + function replaceFunctions( + address _facet, + bytes4[] memory _selectors + ) internal { + if (_selectors.length == 0) revert LibDiamond__NoSelectors(); + + DiamondStorage storage ds = diamondStorage(); + + if (_facet == address(0)) revert LibDiamond__InvalidAddressZero(); + + uint96 selectorPosition = uint96( + ds.facetFunctionSelectors[_facet].functionSelectors.length + ); + + /// @notice Add a new facet address if it does not exists already + + if (selectorPosition == 0) addFacet(ds, _facet); + + for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { + bytes4 selector = _selectors[selectorIndex]; + + address oldFacetAddress = ds + .selectorToFacetAndPosition[selector] + .facetAddress; + + if (oldFacetAddress == _facet) + revert LibDiamond__InvalidReplacementWithSameFunction(); + + removeFunction(ds, oldFacetAddress, selector); + + addFunction(ds, selector, selectorPosition, _facet); + + /// @notice Realistically impossible to overflow/underflow + unchecked { + ++selectorIndex; + ++selectorPosition; + } + } + } + + /// @notice Remove functions inside the diamond + /// @param _facet Address of the facet + /// @param _selectors Selectors of the facet + function removeFunctions( + address _facet, + bytes4[] memory _selectors + ) internal { + if (_selectors.length == 0) revert LibDiamond__NoSelectors(); + + DiamondStorage storage ds = diamondStorage(); + + if (_facet != address(0)) revert LibDiamond__AddressMustBeZero(); + + for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { + bytes4 selector = _selectors[selectorIndex]; + + address oldFacetAddress = ds + .selectorToFacetAndPosition[selector] + .facetAddress; + + removeFunction(ds, oldFacetAddress, selector); + + /// @notice Realistically impossible to overflow/underflow + unchecked { + ++selectorIndex; + } + } + } + + /// @notice Add facet to the diamond + /// @param ds DiamondStorage + /// @param _facet Address of the diamond + function addFacet(DiamondStorage storage ds, address _facet) internal { + enforceHasContractCode(_facet); + + ds.facetFunctionSelectors[_facet].facetAddressPosition = ds + .facetAddresses + .length; + ds.facetAddresses.push(_facet); + } + + /// @notice Add a function to the diamond + /// @param ds DiamondStorage + /// @param _selector Selector of the function + /// @param _positon Position of the selector + /// @param _facet Address of the function + function addFunction( + DiamondStorage storage ds, + bytes4 _selector, + uint96 _positon, + address _facet + ) internal { + ds + .selectorToFacetAndPosition[_selector] + .functionSelectorPosition = _positon; + ds.facetFunctionSelectors[_facet].functionSelectors.push(_selector); + ds.selectorToFacetAndPosition[_selector].facetAddress = _facet; + } + + /// @notice Remove a function from the diamond + /// @param ds DiamondStorage + /// @param _facet Address of the facet + /// @param _selector Selector of the function + function removeFunction( + DiamondStorage storage ds, + address _facet, + bytes4 _selector + ) internal { + if (_facet == address(0)) revert LibDiamond__InexistentFunction(); + + /// @notice An immutable function is defined directly inside the diamond + if (_facet == address(this)) revert LibDiamond__ImmutableFunction(); + + /// @notice Replaces selector with the last selector, then deletes the last selector + uint256 selectorPosition = ds + .selectorToFacetAndPosition[_selector] + .functionSelectorPosition; + uint256 lastSelectorPosition = ds + .facetFunctionSelectors[_facet] + .functionSelectors + .length - 1; + + /// @notice Replaces `_selector` with `lastSelector`, if not, they are not the same + if (selectorPosition != lastSelectorPosition) { + bytes4 lastSelector = ds + .facetFunctionSelectors[_facet] + .functionSelectors[lastSelectorPosition]; + + ds.facetFunctionSelectors[_facet].functionSelectors[ + selectorPosition + ] = lastSelector; + ds + .selectorToFacetAndPosition[lastSelector] + .functionSelectorPosition = uint96(selectorPosition); + } + + /// @notice Deletes the last selector + + ds.facetFunctionSelectors[_facet].functionSelectors.pop(); + + delete ds.selectorToFacetAndPosition[_selector]; + + /// @notice Deletes the facet address if there are no more selectors for the facet address + if (lastSelectorPosition == 0) { + /// @notice Replaces facet address with the last facet address, then deletes the last facet address + uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1; + uint256 facetAddressPosition = ds + .facetFunctionSelectors[_facet] + .facetAddressPosition; + + if (facetAddressPosition != lastFacetAddressPosition) { + address lastFacetAddress = ds.facetAddresses[ + lastFacetAddressPosition + ]; + + ds.facetAddresses[facetAddressPosition] = lastFacetAddress; + ds + .facetFunctionSelectors[lastFacetAddress] + .facetAddressPosition = facetAddressPosition; + } + + ds.facetAddresses.pop(); + + delete ds.facetFunctionSelectors[_facet].facetAddressPosition; + } + } + + /// @notice Initialize diamond cut + /// @param _init Address of the initialization contract + /// @param _data Data + function initializeDiamondCut(address _init, bytes memory _data) internal { + if (_init == address(0)) return; + + enforceHasContractCode(_init); + + (bool success, bytes memory error) = _init.delegatecall(_data); + + if (!success) { + if (error.length > 0) { + /// @solidity memory-safe-assembly + assembly { + let dataSize := mload(error) + + revert(add(32, error), dataSize) + } + } else { + revert LibDiamond__InitializationFailed(_init, _data); + } + } + } + + /// @notice Enforce contract has code + /// @param _contract Address of the contract + function enforceHasContractCode(address _contract) internal view { + uint256 contractSize; + + /// @solidity memory-safe-assembly + assembly { + contractSize := extcodesize(_contract) + } + + if (contractSize == 0) revert LibDiamond__InexistentFacetCode(); + } +} diff --git a/contracts/libraries/LibPercentages.sol b/contracts/libraries/LibPercentages.sol new file mode 100644 index 0000000..b4fd7a7 --- /dev/null +++ b/contracts/libraries/LibPercentages.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +library LibPercentages { + /// @notice Calculates the percentage of a number using basis points + /// @dev 1% = 100 basis points + /// @param _number Number + /// @param _percentage Percentage in bps + /// @return Percentage of a number + function percentage( + uint256 _number, + uint256 _percentage + ) internal pure returns (uint256) { + return (_number * _percentage) / 10_000; + } +} diff --git a/contracts/tokens/BondingERC20Token.sol b/contracts/tokens/BondingERC20Token.sol new file mode 100644 index 0000000..63a2fc9 --- /dev/null +++ b/contracts/tokens/BondingERC20Token.sol @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {ERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; +import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; +import {IUniswapV2Factory} from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; + +error NeedToSendETH(); +error NeedToSellTokens(); +error ContractNotEnoughETH(); +error FailedToSendETH(); + +contract BondingERC20Token is ERC20, Ownable, ReentrancyGuard { + IUniswapV2Router02 public immutable router; + IUniswapV2Factory public immutable factory; + address public immutable WETH; + address public constant BURN_ADDRESS = + 0x000000000000000000000000000000000000dEaD; + address public immutable marketing; + address public immutable treasury; + uint public constant INITIAL_PRICE = 1e12; // Initial price per token + uint public constant PRICE_FACTOR = 1e6; // Price factor for logarithmic curve + uint public totalETHContributed; + uint public liquidityGoal = 10 ether; + + constructor( + address _owner, + address _router, + string memory _name, + string memory _symbol + ) ERC20(_name, _symbol) Ownable(_owner) { + router = IUniswapV2Router02(_router); + factory = IUniswapV2Factory(router.factory()); + WETH = router.WETH(); + } + + function buyTokens() external payable { + if (msg.value == 0) revert NeedToSendETH(); + uint tokensToBuy = calculateTokenAmount(msg.value); + _mint(msg.sender, tokensToBuy); + totalETHContributed += msg.value; + if (totalETHContributed >= liquidityGoal) { + createPair(); + } + } + + function sellTokens(uint tokenAmount) external nonReentrant { + if (tokenAmount == 0) revert NeedToSellTokens(); + uint ethAmount = calculateETHAmount(tokenAmount); + if (address(this).balance < ethAmount) revert ContractNotEnoughETH(); + + _burn(msg.sender, tokenAmount); + (bool sent, ) = msg.sender.call{value: ethAmount}(""); + if (!sent) revert FailedToSendETH(); + } + + function calculateTokenAmount(uint ethAmount) public view returns (uint) { + uint currentSupply = totalSupply(); + // Logarithmic bonding curve: price = INITIAL_PRICE * (1 + log(1 + currentSupply / PRICE_FACTOR)) + uint pricePerToken = (INITIAL_PRICE * + (1e18 + log(1e18 + (currentSupply * 1e18) / PRICE_FACTOR))) / 1e18; + return (ethAmount * 1e18) / pricePerToken; + } + + function calculateETHAmount(uint tokenAmount) public view returns (uint) { + uint currentSupply = totalSupply(); + // Assuming you want to use the same price calculation for selling, + // but you might want to adjust this for sell pricing + uint pricePerToken = (INITIAL_PRICE * + (1e18 + log(1e18 + (currentSupply * 1e18) / PRICE_FACTOR))) / 1e18; + return (tokenAmount * pricePerToken) / 1e18; + } + + function createPair() internal { + uint ethAmount = address(this).balance; + uint tokenAmount = this.balanceOf(address(this)); + _approve(address(this), address(router), tokenAmount); + + // Add liquidity + (, , uint liquidity) = router.addLiquidityETH{value: ethAmount}( + address(this), + tokenAmount, + tokenAmount, + ethAmount, + address(this), + block.timestamp + ); + + // Burn the LP tokens received + IERC20 lpToken = IERC20(factory.getPair(address(this), WETH)); + lpToken.transfer(BURN_ADDRESS, liquidity); + } + + function log(uint x) internal pure returns (uint) { + uint res = 0; + while (x >= 1e18) { + x /= 1e18; + res += 1e18; + } + return res; + } + + receive() external payable {} +} diff --git a/contracts/Token.sol b/contracts/tokens/ERC20Token.sol similarity index 85% rename from contracts/Token.sol rename to contracts/tokens/ERC20Token.sol index 73bdea6..5f59dfd 100644 --- a/contracts/Token.sol +++ b/contracts/tokens/ERC20Token.sol @@ -4,15 +4,15 @@ pragma solidity ^0.8.22; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -import {IStratosphere} from "./interfaces/IStratosphere.sol"; +import {IStratosphere} from "../interfaces/IStratosphere.sol"; -error Token__MissingLiquidityPool(); -error Token__ExceedsMaximumHolding(); -error Token__TradingNotStarted(); -error Token__NonStratosphereNFTHolder(); -error Token__BotDetected(); +error ERC20Token__MissingLiquidityPool(); +error ERC20Token__ExceedsMaximumHolding(); +error ERC20Token__TradingNotStarted(); +error ERC20Token__NonStratosphereNFTHolder(); +error ERC20Token__BotDetected(); -contract Token is ERC20, ERC20Permit, Ownable { +contract ERC20Token is ERC20, ERC20Permit, Ownable { address public deployer; address public liquidityPool; address public immutable dexAggregator; @@ -43,7 +43,7 @@ contract Token is ERC20, ERC20Permit, Ownable { function setLiquidityPool(address _liquidityPool) external onlyOwner { if (_liquidityPool == address(0)) { - revert Token__MissingLiquidityPool(); + revert ERC20Token__MissingLiquidityPool(); } liquidityPool = _liquidityPool; } @@ -66,7 +66,7 @@ contract Token is ERC20, ERC20Permit, Ownable { } if (block.timestamp < _tradingStartsAt) { - revert Token__TradingNotStarted(); + revert ERC20Token__TradingNotStarted(); } uint256 _secondsSinceTradingStarted = block.timestamp - @@ -82,7 +82,7 @@ contract Token is ERC20, ERC20Permit, Ownable { !(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to)) ) { - revert Token__NonStratosphereNFTHolder(); + revert ERC20Token__NonStratosphereNFTHolder(); } } else if (_secondsSinceTradingStarted < 24 hours) { _enforceAntiWhale(to, value); @@ -93,7 +93,7 @@ contract Token is ERC20, ERC20Permit, Ownable { if (to != liquidityPool) { uint256 newBalance = balanceOf(to) + value; if (newBalance > maxHoldingAmount) { - revert Token__ExceedsMaximumHolding(); + revert ERC20Token__ExceedsMaximumHolding(); } } } diff --git a/contracts/upgradeInitializers/DiamondInit.sol b/contracts/upgradeInitializers/DiamondInit.sol new file mode 100644 index 0000000..1035e50 --- /dev/null +++ b/contracts/upgradeInitializers/DiamondInit.sol @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +* +* Implementation of a diamond. +/******************************************************************************/ + +import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol"; +import {LibDiamond} from "../libraries/LibDiamond.sol"; +import {IDiamondLoupe} from "../interfaces/IDiamondLoupe.sol"; +import {IDiamondCut} from "../interfaces/IDiamondCut.sol"; +import {IERC173} from "../interfaces/IERC173.sol"; +import {AppStorage} from "../libraries/LibAppStorage.sol"; + +error DiamondInit__WrongDeploymentArguments(); + +// It is expected that this contract is customized if you want to deploy your diamond +// with data from a deployment script. Use the init function to initialize state variables +// of your diamond. Add parameters to the init funciton if you need to. + +// Adding parameters to the `init` or other functions you add here can make a single deployed +// DiamondInit contract reusable accross upgrades, and can be used for multiple diamonds. + +contract DiamondInit { + AppStorage s; + /** + * @dev TokenFactory constructor initializes the contract with required parameters. + * @param routerAddress Address of the VaporDEXRouter contract. + * @param factoryAddress Address of the VaporDEXFactory contract. + * @param stratosphereAddress Address of the Stratosphere contract. + * @param vaporDexAggregator Address of the VaporDEX aggregator. + * @param vaporDexAdapter Address of the VaporDEX adapter. + * @param usdc Address of the USDC token. + * @param vape Address of the VAPE token. + * @param weth Address of the WETH token. + * @param launchFee Launch fee in USDC. + * @param minLiquidityETH Minimum liquidity in ETH. + * @param minLockDuration Minimum lock duration in seconds. + * @param sablier Address of the Sablier contract. + * @param nonFungiblePositionManager Uni v3 NFT Position Manager + * @param teamMultisig Multisig address + * @param slippage + */ + struct DeployArgs { + address routerAddress; + address factoryAddress; + address stratosphereAddress; + address vaporDexAggregator; + address vaporDexAdapter; + address usdc; + address vape; + address weth; + uint256 launchFee; + uint256 minLiquidityETH; + uint40 minLockDuration; + address sablier; + address nonFungiblePositionManager; + address teamMultisig; + uint256 slippage; + } + + // You can add parameters to this function in order to pass in + // data to set your own state variables + function init(DeployArgs memory _args) external { + // adding ERC165 data + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + ds.supportedInterfaces[type(IERC165).interfaceId] = true; + ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true; + ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true; + ds.supportedInterfaces[type(IERC173).interfaceId] = true; + + // add your own state variables + // EIP-2535 specifies that the `diamondCut` function takes two optional + // arguments: address _init and bytes calldata _calldata + // These arguments are used to execute an arbitrary function using delegatecall + // in order to set state variables in the diamond during deployment or an upgrade + // More info here: https://eips.ethereum.org/EIPS/eip-2535#diamond-interface + + // Check for valid constructor arguments + if ( + _args.routerAddress == address(0) || + _args.stratosphereAddress == address(0) || + _args.vaporDexAggregator == address(0) || + _args.vaporDexAdapter == address(0) || + _args.usdc == address(0) || + _args.launchFee == 0 || + _args.sablier == address(0) || + _args.minLiquidityETH == 0 || + _args.minLockDuration == 0 || + _args.weth == address(0) || + _args.nonFungiblePositionManager == address(0) || + _args.teamMultisig == address(0) + ) { + revert DiamondInit__WrongDeploymentArguments(); + } + + s.vaporDEXRouter = _args.routerAddress; + s.vaporDEXFactory = _args.factoryAddress; + s.stratosphere = _args.stratosphereAddress; + s.vaporDEXAggregator = _args.vaporDexAggregator; + s.vaporDEXAdapter = _args.vaporDexAdapter; + s.USDC = _args.usdc; + s.VAPE = _args.vape; + s.WETH = _args.weth; + s.launchFee = _args.launchFee; + s.minLiquidityETH = _args.minLiquidityETH; + s.minLockDuration = _args.minLockDuration; + s.sablier = _args.sablier; + s.nonFungiblePositionManager = _args.nonFungiblePositionManager; + s.teamMultisig = _args.teamMultisig; + s.slippage = _args.slippage; + } +} diff --git a/contracts/utils/CREATE3Factory.sol b/contracts/utils/CREATE3Factory.sol new file mode 100644 index 0000000..645af42 --- /dev/null +++ b/contracts/utils/CREATE3Factory.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {CREATE3} from "solmate/src/utils/CREATE3.sol"; + +contract CREATE3Factory { + function deploy( + bytes32 salt, + bytes memory creationCode + ) external payable returns (address deployed) { + // hash salt with the deployer address to give each deployer its own namespace + salt = keccak256(abi.encodePacked(msg.sender, salt)); + return CREATE3.deploy(salt, creationCode, msg.value); + } + + function getDeployed( + address deployer, + bytes32 salt + ) external view returns (address deployed) { + // hash salt with the deployer address to give each deployer its own namespace + salt = keccak256(abi.encodePacked(deployer, salt)); + return CREATE3.getDeployed(salt); + } +} diff --git a/deploy/01_deploy_factory.ts b/deploy/01_deploy_factory.ts deleted file mode 100644 index fa11046..0000000 --- a/deploy/01_deploy_factory.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { HardhatRuntimeEnvironment } from "hardhat/types"; -import { DeployFunction } from "hardhat-deploy/types"; -import { addresses, config } from "../config"; -import { TokenFactory } from "../typechain-types/index"; - -const func: DeployFunction = async function ({ - getNamedAccounts, - deployments, - network, -}: HardhatRuntimeEnvironment) { - const chainId = network.config.chainId; - - if (!chainId) { - throw new Error("ChainId not found"); - } - const args: TokenFactory.DeployArgsStruct = { - owner: addresses.teamMultiSig[chainId], - routerAddress: addresses.vaporDexRouter[chainId], - stratosphereAddress: addresses.stratosphereNFT[chainId], - vaporDexAggregator: addresses.vaporDexAggregatorRouter[chainId], - vaporDexAdapter: addresses.vaporDexAggregatorAdapter[chainId], - usdc: addresses.usdc[chainId], - vape: addresses.vape[chainId], - launchFee: config.launchFeeUSDC[chainId], - minLiquidityETH: config.minimumNative[chainId], - minLockDuration: config.minimumLockDuration[chainId], - sablier: addresses.sablier[chainId], - nonFungiblePositionManager: addresses.nonFungiblePositionManager[chainId], - teamMultisig: addresses.teamMultiSig[chainId], - slippage: config.slippage[chainId], - }; - - const { deploy } = deployments; - const { deployer } = await getNamedAccounts(); - await deploy("TokenFactory", { - from: deployer, - args: [args], - log: true, - }); -}; - -export default func; - -func.tags = ["TokenFactory"]; diff --git a/deployments/AdminFacet.json b/deployments/AdminFacet.json new file mode 100644 index 0000000..aafe418 --- /dev/null +++ b/deployments/AdminFacet.json @@ -0,0 +1,604 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "AdminFacet", + "sourceName": "contracts/facets/AdminFacet.sol", + "abi": [ + { + "inputs": [], + "name": "AdminFacet__Invalid", + "type": "error" + }, + { + "inputs": [], + "name": "AdminFacet__ZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "AccumulatedFeesWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_launchFee", + "type": "uint256" + } + ], + "name": "LaunchFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_liquidity", + "type": "uint256" + } + ], + "name": "MinimumLiquidityETHUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint40", + "name": "_lockDuration", + "type": "uint40" + } + ], + "name": "MinimumLockDurationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_slippage", + "type": "uint256" + } + ], + "name": "SlippageUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_vaporDexAdapter", + "type": "address" + } + ], + "name": "VaporDEXAdapterUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "getLaunchFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "getTokenDetails", + "outputs": [ + { + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tradingStartsAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "getTokenLaunches", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVaporDEXAdapter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_launchFee", + "type": "uint256" + } + ], + "name": "setLaunchFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint40", + "name": "_lockDuration", + "type": "uint40" + } + ], + "name": "setMinLockDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_liquidity", + "type": "uint256" + } + ], + "name": "setMinimumLiquidityETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_slippage", + "type": "uint256" + } + ], + "name": "setSlippage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_vaporDexAdapter", + "type": "address" + } + ], + "name": "setVaporDEXAdapter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "withdrawFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b50610b878061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c8063581c59591161007657806388dcaa6d1161005b57806388dcaa6d146101bb578063bd26b795146101cc578063f0fa55a9146101df57600080fd5b8063581c59591461013a57806388aa8bee1461016257600080fd5b80631e4dfd25116100a75780631e4dfd25146100eb5780631fef0820146101145780635313be2c1461012757600080fd5b8063121b40b6146100c35780631ac3ddeb146100d8575b600080fd5b6100d66100d1366004610a3b565b6101f2565b005b6100d66100e6366004610a3b565b6102e8565b6100fe6100f9366004610a3b565b610555565b60405161010b9190610a5f565b60405180910390f35b6100d6610122366004610ab9565b6105e5565b6100d6610135366004610ae0565b610692565b60055460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161010b565b610175610170366004610a3b565b610709565b6040805173ffffffffffffffffffffffffffffffffffffffff9687168152948616602086015292909416918301919091526060820152608081019190915260a00161010b565b600c5460405190815260200161010b565b6100d66101da366004610ae0565b6108ab565b6100d66101ed366004610ae0565b610922565b6101fa61095f565b60055473ffffffffffffffffffffffffffffffffffffffff82811691161480610237575073ffffffffffffffffffffffffffffffffffffffff8116155b1561026e576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdbe246cfe804b22936a913bd3b7c4afe2ff6632dcf29b6ec8dc2fff938161e3a906020015b60405180910390a150565b6102f061095f565b73ffffffffffffffffffffffffffffffffffffffff811661033d576040517fe0029d2f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff90911690819063a9059cbb90849083906370a0823190602401602060405180830381865afa1580156103b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103db9190610af9565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af115801561044b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046f9190610b12565b506040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201527f6c04bc1888e3e83b48fb5da89a0077db3746574bb4bbd7ac7ee7689f9c1c7f0c90839073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa1580156104fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105229190610af9565b6040805173ffffffffffffffffffffffffffffffffffffffff909316835260208301919091520160405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601160209081526040918290208054835181840281018401909452808452606093928301828280156105d957602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116105ae575b50505050509050919050565b6105ed61095f565b8064ffffffffff1660000361062e576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff83169081179091556040519081527f73e38b32aad3b3e0d429bc819e2d79b4712f86c083bacf669d22ab304fe5888d906020016102dd565b61069a61095f565b806000036106d4576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c8190556040518181527fc799be5eb19a1a6d6ba7368d21e2bc367c8a335e4a07cd3d954482e6f714d3c5906020016102dd565b6000806000806000808690508073ffffffffffffffffffffffffffffffffffffffff1663d5f394886040518163ffffffff1660e01b8152600401602060405180830381865afa158015610760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107849190610b34565b95508094508073ffffffffffffffffffffffffffffffffffffffff1663665a11ca6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f89190610b34565b93508073ffffffffffffffffffffffffffffffffffffffff1663fe4c4af46040518163ffffffff1660e01b8152600401602060405180830381865afa158015610845573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108699190610af9565b73ffffffffffffffffffffffffffffffffffffffff8088166000908152601260209081526040808320938a168352929052205496989597509395939492505050565b6108b361095f565b806000036108ed576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600d8190556040518181527f1fd55d90af4abf6458d9caa4afe3590d7a8ea749b373a53114a7273fe7c8b631906020016102dd565b61092a61095f565b600e8190556040518181527ff5a802650e0a86db227cc342f06327d2ca0ff5cf2b12e0084fc5d8a7db2c54fd906020016102dd565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff163314610a14577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b73ffffffffffffffffffffffffffffffffffffffff81168114610a3857600080fd5b50565b600060208284031215610a4d57600080fd5b8135610a5881610a16565b9392505050565b6020808252825182820181905260009190848201906040850190845b81811015610aad57835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610a7b565b50909695505050505050565b600060208284031215610acb57600080fd5b813564ffffffffff81168114610a5857600080fd5b600060208284031215610af257600080fd5b5035919050565b600060208284031215610b0b57600080fd5b5051919050565b600060208284031215610b2457600080fd5b81518015158114610a5857600080fd5b600060208284031215610b4657600080fd5b8151610a5881610a1656fea26469706673582212208a8f4e72daaff845dceb98274806caf8e327f977ba59e276cbca6a51a4ba6a3e64736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100be5760003560e01c8063581c59591161007657806388dcaa6d1161005b57806388dcaa6d146101bb578063bd26b795146101cc578063f0fa55a9146101df57600080fd5b8063581c59591461013a57806388aa8bee1461016257600080fd5b80631e4dfd25116100a75780631e4dfd25146100eb5780631fef0820146101145780635313be2c1461012757600080fd5b8063121b40b6146100c35780631ac3ddeb146100d8575b600080fd5b6100d66100d1366004610a3b565b6101f2565b005b6100d66100e6366004610a3b565b6102e8565b6100fe6100f9366004610a3b565b610555565b60405161010b9190610a5f565b60405180910390f35b6100d6610122366004610ab9565b6105e5565b6100d6610135366004610ae0565b610692565b60055460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161010b565b610175610170366004610a3b565b610709565b6040805173ffffffffffffffffffffffffffffffffffffffff9687168152948616602086015292909416918301919091526060820152608081019190915260a00161010b565b600c5460405190815260200161010b565b6100d66101da366004610ae0565b6108ab565b6100d66101ed366004610ae0565b610922565b6101fa61095f565b60055473ffffffffffffffffffffffffffffffffffffffff82811691161480610237575073ffffffffffffffffffffffffffffffffffffffff8116155b1561026e576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdbe246cfe804b22936a913bd3b7c4afe2ff6632dcf29b6ec8dc2fff938161e3a906020015b60405180910390a150565b6102f061095f565b73ffffffffffffffffffffffffffffffffffffffff811661033d576040517fe0029d2f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff90911690819063a9059cbb90849083906370a0823190602401602060405180830381865afa1580156103b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103db9190610af9565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af115801561044b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046f9190610b12565b506040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201527f6c04bc1888e3e83b48fb5da89a0077db3746574bb4bbd7ac7ee7689f9c1c7f0c90839073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa1580156104fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105229190610af9565b6040805173ffffffffffffffffffffffffffffffffffffffff909316835260208301919091520160405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601160209081526040918290208054835181840281018401909452808452606093928301828280156105d957602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116105ae575b50505050509050919050565b6105ed61095f565b8064ffffffffff1660000361062e576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff83169081179091556040519081527f73e38b32aad3b3e0d429bc819e2d79b4712f86c083bacf669d22ab304fe5888d906020016102dd565b61069a61095f565b806000036106d4576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c8190556040518181527fc799be5eb19a1a6d6ba7368d21e2bc367c8a335e4a07cd3d954482e6f714d3c5906020016102dd565b6000806000806000808690508073ffffffffffffffffffffffffffffffffffffffff1663d5f394886040518163ffffffff1660e01b8152600401602060405180830381865afa158015610760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107849190610b34565b95508094508073ffffffffffffffffffffffffffffffffffffffff1663665a11ca6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f89190610b34565b93508073ffffffffffffffffffffffffffffffffffffffff1663fe4c4af46040518163ffffffff1660e01b8152600401602060405180830381865afa158015610845573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108699190610af9565b73ffffffffffffffffffffffffffffffffffffffff8088166000908152601260209081526040808320938a168352929052205496989597509395939492505050565b6108b361095f565b806000036108ed576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600d8190556040518181527f1fd55d90af4abf6458d9caa4afe3590d7a8ea749b373a53114a7273fe7c8b631906020016102dd565b61092a61095f565b600e8190556040518181527ff5a802650e0a86db227cc342f06327d2ca0ff5cf2b12e0084fc5d8a7db2c54fd906020016102dd565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff163314610a14577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b73ffffffffffffffffffffffffffffffffffffffff81168114610a3857600080fd5b50565b600060208284031215610a4d57600080fd5b8135610a5881610a16565b9392505050565b6020808252825182820181905260009190848201906040850190845b81811015610aad57835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610a7b565b50909695505050505050565b600060208284031215610acb57600080fd5b813564ffffffffff81168114610a5857600080fd5b600060208284031215610af257600080fd5b5035919050565b600060208284031215610b0b57600080fd5b5051919050565b600060208284031215610b2457600080fd5b81518015158114610a5857600080fd5b600060208284031215610b4657600080fd5b8151610a5881610a1656fea26469706673582212208a8f4e72daaff845dceb98274806caf8e327f977ba59e276cbca6a51a4ba6a3e64736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0xfb84E33431C7FB711bEE10c1F40aD2D134edD03D" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "AdminFacet", + "sourceName": "contracts/facets/AdminFacet.sol", + "abi": [ + { + "inputs": [], + "name": "AdminFacet__InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "AdminFacet__Invalid", + "type": "error" + }, + { + "inputs": [], + "name": "AdminFacet__ZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_balance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "EmergencyWithdraw", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_launchFee", + "type": "uint256" + } + ], + "name": "LaunchFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_liquidity", + "type": "uint256" + } + ], + "name": "MinimumLiquidityETHUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint40", + "name": "_lockDuration", + "type": "uint40" + } + ], + "name": "MinimumLockDurationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_slippage", + "type": "uint256" + } + ], + "name": "SlippageUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_vaporDexAdapter", + "type": "address" + } + ], + "name": "VaporDEXAdapterUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "emergencyWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getLaunchFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "getTokenDetails", + "outputs": [ + { + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tradingStartsAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "getTokenLaunches", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVaporDEXAdapter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_launchFee", + "type": "uint256" + } + ], + "name": "setLaunchFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint40", + "name": "_lockDuration", + "type": "uint40" + } + ], + "name": "setMinLockDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_liquidity", + "type": "uint256" + } + ], + "name": "setMinimumLiquidityETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_slippage", + "type": "uint256" + } + ], + "name": "setSlippage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_vaporDexAdapter", + "type": "address" + } + ], + "name": "setVaporDEXAdapter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b50610b888061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c80636382d9ad1161007657806388dcaa6d1161005b57806388dcaa6d146101bb578063bd26b795146101cc578063f0fa55a9146101df57600080fd5b80636382d9ad1461014f57806388aa8bee1461016257600080fd5b80631fef0820116100a75780631fef0820146101015780635313be2c14610114578063581c59591461012757600080fd5b8063121b40b6146100c35780631e4dfd25146100d8575b600080fd5b6100d66100d1366004610a03565b6101f2565b005b6100eb6100e6366004610a03565b6102e8565b6040516100f89190610a27565b60405180910390f35b6100d661010f366004610a81565b610378565b6100d6610122366004610aa8565b610425565b60055460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f8565b6100d661015d366004610ac1565b61049c565b610175610170366004610a03565b6106d1565b6040805173ffffffffffffffffffffffffffffffffffffffff9687168152948616602086015292909416918301919091526060820152608081019190915260a0016100f8565b600c546040519081526020016100f8565b6100d66101da366004610aa8565b610873565b6100d66101ed366004610aa8565b6108ea565b6101fa610927565b60055473ffffffffffffffffffffffffffffffffffffffff82811691161480610237575073ffffffffffffffffffffffffffffffffffffffff8116155b1561026e576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdbe246cfe804b22936a913bd3b7c4afe2ff6632dcf29b6ec8dc2fff938161e3a906020015b60405180910390a150565b73ffffffffffffffffffffffffffffffffffffffff811660009081526011602090815260409182902080548351818402810184019094528084526060939283018282801561036c57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610341575b50505050509050919050565b610380610927565b8064ffffffffff166000036103c1576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff83169081179091556040519081527f73e38b32aad3b3e0d429bc819e2d79b4712f86c083bacf669d22ab304fe5888d906020016102dd565b61042d610927565b80600003610467576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c8190556040518181527fc799be5eb19a1a6d6ba7368d21e2bc367c8a335e4a07cd3d954482e6f714d3c5906020016102dd565b6104a4610927565b73ffffffffffffffffffffffffffffffffffffffff811615806104db575073ffffffffffffffffffffffffffffffffffffffff8216155b15610512576040517fe0029d2f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829060009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015610581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a59190610afa565b9050806000036105e1576040517f2529503a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af1158015610656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067a9190610b13565b5060405173ffffffffffffffffffffffffffffffffffffffff84811682528291908616907faaeda929aa102e867049528ec7cd2499e3a2f8846e736ae7935f234dfbf500d99060200160405180910390a350505050565b6000806000806000808690508073ffffffffffffffffffffffffffffffffffffffff1663d5f394886040518163ffffffff1660e01b8152600401602060405180830381865afa158015610728573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074c9190610b35565b95508094508073ffffffffffffffffffffffffffffffffffffffff1663665a11ca6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561079c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c09190610b35565b93508073ffffffffffffffffffffffffffffffffffffffff1663fe4c4af46040518163ffffffff1660e01b8152600401602060405180830381865afa15801561080d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108319190610afa565b73ffffffffffffffffffffffffffffffffffffffff8088166000908152601260209081526040808320938a168352929052205496989597509395939492505050565b61087b610927565b806000036108b5576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600d8190556040518181527f1fd55d90af4abf6458d9caa4afe3590d7a8ea749b373a53114a7273fe7c8b631906020016102dd565b6108f2610927565b600e8190556040518181527ff5a802650e0a86db227cc342f06327d2ca0ff5cf2b12e0084fc5d8a7db2c54fd906020016102dd565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff1633146109dc577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b73ffffffffffffffffffffffffffffffffffffffff81168114610a0057600080fd5b50565b600060208284031215610a1557600080fd5b8135610a20816109de565b9392505050565b6020808252825182820181905260009190848201906040850190845b81811015610a7557835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610a43565b50909695505050505050565b600060208284031215610a9357600080fd5b813564ffffffffff81168114610a2057600080fd5b600060208284031215610aba57600080fd5b5035919050565b60008060408385031215610ad457600080fd5b8235610adf816109de565b91506020830135610aef816109de565b809150509250929050565b600060208284031215610b0c57600080fd5b5051919050565b600060208284031215610b2557600080fd5b81518015158114610a2057600080fd5b600060208284031215610b4757600080fd5b8151610a20816109de56fea2646970667358221220c9a099f873d1d4ae148fc43744a60ae327c6f810dd977469ab888fd22646463464736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100be5760003560e01c80636382d9ad1161007657806388dcaa6d1161005b57806388dcaa6d146101bb578063bd26b795146101cc578063f0fa55a9146101df57600080fd5b80636382d9ad1461014f57806388aa8bee1461016257600080fd5b80631fef0820116100a75780631fef0820146101015780635313be2c14610114578063581c59591461012757600080fd5b8063121b40b6146100c35780631e4dfd25146100d8575b600080fd5b6100d66100d1366004610a03565b6101f2565b005b6100eb6100e6366004610a03565b6102e8565b6040516100f89190610a27565b60405180910390f35b6100d661010f366004610a81565b610378565b6100d6610122366004610aa8565b610425565b60055460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f8565b6100d661015d366004610ac1565b61049c565b610175610170366004610a03565b6106d1565b6040805173ffffffffffffffffffffffffffffffffffffffff9687168152948616602086015292909416918301919091526060820152608081019190915260a0016100f8565b600c546040519081526020016100f8565b6100d66101da366004610aa8565b610873565b6100d66101ed366004610aa8565b6108ea565b6101fa610927565b60055473ffffffffffffffffffffffffffffffffffffffff82811691161480610237575073ffffffffffffffffffffffffffffffffffffffff8116155b1561026e576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdbe246cfe804b22936a913bd3b7c4afe2ff6632dcf29b6ec8dc2fff938161e3a906020015b60405180910390a150565b73ffffffffffffffffffffffffffffffffffffffff811660009081526011602090815260409182902080548351818402810184019094528084526060939283018282801561036c57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610341575b50505050509050919050565b610380610927565b8064ffffffffff166000036103c1576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff83169081179091556040519081527f73e38b32aad3b3e0d429bc819e2d79b4712f86c083bacf669d22ab304fe5888d906020016102dd565b61042d610927565b80600003610467576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c8190556040518181527fc799be5eb19a1a6d6ba7368d21e2bc367c8a335e4a07cd3d954482e6f714d3c5906020016102dd565b6104a4610927565b73ffffffffffffffffffffffffffffffffffffffff811615806104db575073ffffffffffffffffffffffffffffffffffffffff8216155b15610512576040517fe0029d2f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829060009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015610581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a59190610afa565b9050806000036105e1576040517f2529503a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af1158015610656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067a9190610b13565b5060405173ffffffffffffffffffffffffffffffffffffffff84811682528291908616907faaeda929aa102e867049528ec7cd2499e3a2f8846e736ae7935f234dfbf500d99060200160405180910390a350505050565b6000806000806000808690508073ffffffffffffffffffffffffffffffffffffffff1663d5f394886040518163ffffffff1660e01b8152600401602060405180830381865afa158015610728573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074c9190610b35565b95508094508073ffffffffffffffffffffffffffffffffffffffff1663665a11ca6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561079c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c09190610b35565b93508073ffffffffffffffffffffffffffffffffffffffff1663fe4c4af46040518163ffffffff1660e01b8152600401602060405180830381865afa15801561080d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108319190610afa565b73ffffffffffffffffffffffffffffffffffffffff8088166000908152601260209081526040808320938a168352929052205496989597509395939492505050565b61087b610927565b806000036108b5576040517f674a0b2200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600d8190556040518181527f1fd55d90af4abf6458d9caa4afe3590d7a8ea749b373a53114a7273fe7c8b631906020016102dd565b6108f2610927565b600e8190556040518181527ff5a802650e0a86db227cc342f06327d2ca0ff5cf2b12e0084fc5d8a7db2c54fd906020016102dd565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff1633146109dc577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b73ffffffffffffffffffffffffffffffffffffffff81168114610a0057600080fd5b50565b600060208284031215610a1557600080fd5b8135610a20816109de565b9392505050565b6020808252825182820181905260009190848201906040850190845b81811015610a7557835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610a43565b50909695505050505050565b600060208284031215610a9357600080fd5b813564ffffffffff81168114610a2057600080fd5b600060208284031215610aba57600080fd5b5035919050565b60008060408385031215610ad457600080fd5b8235610adf816109de565b91506020830135610aef816109de565b809150509250929050565b600060208284031215610b0c57600080fd5b5051919050565b600060208284031215610b2557600080fd5b81518015158114610a2057600080fd5b600060208284031215610b4757600080fd5b8151610a20816109de56fea2646970667358221220c9a099f873d1d4ae148fc43744a60ae327c6f810dd977469ab888fd22646463464736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x25510442C0D2870dBcd043501B957524584Ab18f" + } +} \ No newline at end of file diff --git a/deployments/AuthorizationFacet.json b/deployments/AuthorizationFacet.json new file mode 100644 index 0000000..673e02b --- /dev/null +++ b/deployments/AuthorizationFacet.json @@ -0,0 +1,166 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "AuthorizationFacet", + "sourceName": "contracts/facets/AuthorizationFacet.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "authorized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "unAuthorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506102908061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80633bbbc7c914610046578063b6a5d7de1461005b578063b91816111461006e575b600080fd5b61005961005436600461021d565b6100bb565b005b61005961006936600461021d565b61010f565b6100a761007c36600461021d565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205460ff1690565b604051901515815260200160405180910390f35b6100c3610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b610117610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461021b577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b60006020828403121561022f57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461025357600080fd5b939250505056fea2646970667358221220d7c028645cb6cae4cc5d20fb032f48a9f8714feb527c48af443c8cf4577f3b8564736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80633bbbc7c914610046578063b6a5d7de1461005b578063b91816111461006e575b600080fd5b61005961005436600461021d565b6100bb565b005b61005961006936600461021d565b61010f565b6100a761007c36600461021d565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205460ff1690565b604051901515815260200160405180910390f35b6100c3610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b610117610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461021b577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b60006020828403121561022f57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461025357600080fd5b939250505056fea2646970667358221220d7c028645cb6cae4cc5d20fb032f48a9f8714feb527c48af443c8cf4577f3b8564736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0xDA9f756dFfa9Bc04f02E6a14638f5b0336BA2f57" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "AuthorizationFacet", + "sourceName": "contracts/facets/AuthorizationFacet.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "authorized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "unAuthorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506102908061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80633bbbc7c914610046578063b6a5d7de1461005b578063b91816111461006e575b600080fd5b61005961005436600461021d565b6100bb565b005b61005961006936600461021d565b61010f565b6100a761007c36600461021d565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205460ff1690565b604051901515815260200160405180910390f35b6100c3610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b610117610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461021b577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b60006020828403121561022f57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461025357600080fd5b939250505056fea2646970667358221220d7c028645cb6cae4cc5d20fb032f48a9f8714feb527c48af443c8cf4577f3b8564736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80633bbbc7c914610046578063b6a5d7de1461005b578063b91816111461006e575b600080fd5b61005961005436600461021d565b6100bb565b005b61005961006936600461021d565b61010f565b6100a761007c36600461021d565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205460ff1690565b604051901515815260200160405180910390f35b6100c3610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b610117610166565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461021b577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b60006020828403121561022f57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461025357600080fd5b939250505056fea2646970667358221220d7c028645cb6cae4cc5d20fb032f48a9f8714feb527c48af443c8cf4577f3b8564736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x07b1549fB6692e0E6e2C406919d956E350d65731" + } +} \ No newline at end of file diff --git a/deployments/CREATE3Factory.json b/deployments/CREATE3Factory.json new file mode 100644 index 0000000..88dac3c --- /dev/null +++ b/deployments/CREATE3Factory.json @@ -0,0 +1,278 @@ +{ + "telosTestnet": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "CREATE3Factory", + "sourceName": "src/utils/CREATE3Factory.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "creationCode", + "type": "bytes" + } + ], + "name": "deploy", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "getDeployed", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5061063b806100206000396000f3fe6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "deployedBytecode": "0x6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x8f3b1d04C01621553ee04A7B118844c356307f14" + }, + "fuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "CREATE3Factory", + "sourceName": "src/utils/CREATE3Factory.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "creationCode", + "type": "bytes" + } + ], + "name": "deploy", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "getDeployed", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5061063b806100206000396000f3fe6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "deployedBytecode": "0x6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x8f3b1d04C01621553ee04A7B118844c356307f14" + }, + "telos": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "CREATE3Factory", + "sourceName": "src/utils/CREATE3Factory.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "creationCode", + "type": "bytes" + } + ], + "name": "deploy", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "getDeployed", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5061063b806100206000396000f3fe6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "deployedBytecode": "0x6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x8f3b1d04C01621553ee04A7B118844c356307f14" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "CREATE3Factory", + "sourceName": "src/utils/CREATE3Factory.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "creationCode", + "type": "bytes" + } + ], + "name": "deploy", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "getDeployed", + "outputs": [ + { + "internalType": "address", + "name": "deployed", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5061063b806100206000396000f3fe6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "deployedBytecode": "0x6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220ccf150af1277e49b1ff1dc618e3e3618595acb310fbafa353b90c2fe48269ebe64736f6c63430008170033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x8f3b1d04C01621553ee04A7B118844c356307f14" + } +} \ No newline at end of file diff --git a/deployments/DiamondCutFacet.json b/deployments/DiamondCutFacet.json new file mode 100644 index 0000000..10dd2c1 --- /dev/null +++ b/deployments/DiamondCutFacet.json @@ -0,0 +1,446 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "DiamondCutFacet", + "sourceName": "contracts/facets/DiamondCutFacet.sol", + "abi": [ + { + "inputs": [], + "name": "LibDiamond__AddressMustBeZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__FunctionAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__ImmutableFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__IncorrectAction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFacetCode", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LibDiamond__InitializationFailed", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidAddressZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidReplacementWithSameFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__NoSelectors", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_cut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_cut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b5061168f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004611087565b610045565b005b61004d61009e565b61009761005a8587611204565b8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061015692505050565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff163314610154577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546040517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201523360248201526044015b60405180910390fd5b565b60005b83518110156102ec57600084828151811061017657610176611360565b6020026020010151602001519050600060028111156101975761019761138f565b8160028111156101a9576101a961138f565b036101f7576101f28583815181106101c3576101c3611360565b6020026020010151600001518684815181106101e1576101e1611360565b602002602001015160400151610337565b6102e3565b600181600281111561020b5761020b61138f565b03610254576101f285838151811061022557610225611360565b60200260200101516000015186848151811061024357610243611360565b6020026020010151604001516105d0565b60028160028111156102685761026861138f565b036102b1576101f285838151811061028257610282611360565b6020026020010151600001518684815181106102a0576102a0611360565b602002602001015160400151610879565b6040517fdb62f38a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600101610159565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103209392919061142c565b60405180910390a161033282826109b5565b505050565b8051600003610372576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff83166103e0576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff82169003610428576104288285610a95565b60005b835181101561009757600084828151811061044857610448611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff1680156104d7576040517ffbdfc64e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff00000000000000000000000000000000000000001617905550506001918201910161042b565b805160000361060b576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff8316610679576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff821690036106c1576106c18285610a95565b60005b83518110156100975760008482815181106106e1576106e1611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff9081169087168103610775576040517fb4a10fbb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610780858284610b0b565b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff0000000000000000000000000000000000000000161790555050600191820191016106c4565b80516000036108b4576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff831615610923576040517f9d78f07d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82518110156109af57600083828151811061094357610943611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff166109a5848284610b0b565b5050600101610926565b50505050565b73ffffffffffffffffffffffffffffffffffffffff82166109d4575050565b6109dd82610fd4565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610a059190611597565b600060405180830381855af49150503d8060008114610a40576040519150601f19603f3d011682016040523d82523d6000602084013e610a45565b606091505b5091509150816109af57805115610a5f5780518082602001fd5b83836040517f4ecac2bb00000000000000000000000000000000000000000000000000000000815260040161014b9291906115b3565b610a9e81610fd4565b60028201805473ffffffffffffffffffffffffffffffffffffffff90921660008181526001948501602090815260408220860185905594840183559182529290200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169091179055565b73ffffffffffffffffffffffffffffffffffffffff8216610b58576040517f5e9bd5a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff831603610ba7576040517ff12e329600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081166000908152602084815260408083205473ffffffffffffffffffffffffffffffffffffffff86168452600180880190935290832054740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff169291610c31916115ea565b9050808214610d785773ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260408120805483908110610c7357610c73611360565b6000918252602080832060088304015473ffffffffffffffffffffffffffffffffffffffff8916845260018a019091526040909220805460079092166004026101000a90920460e01b925082919085908110610cd157610cd1611360565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790557fffffffff0000000000000000000000000000000000000000000000000000000092909216825286905260409020805473ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000006bffffffffffffffffffffffff8516021790555b73ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260409020805480610dae57610dae61162a565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff000000000000000000000000000000000000000000000000000000008516825286905260408120819055819003610097576002850154600090610e47906001906115ea565b73ffffffffffffffffffffffffffffffffffffffff86166000908152600180890160205260409091200154909150808214610f35576000876002018381548110610e9357610e93611360565b60009182526020909120015460028901805473ffffffffffffffffffffffffffffffffffffffff9092169250829184908110610ed157610ed1611360565b600091825260208083209190910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff948516179055929091168152600189810190925260409020018190555b86600201805480610f4857610f4861162a565b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905590920190925573ffffffffffffffffffffffffffffffffffffffff88168252600189810190915260408220015550505050505050565b803b6000819003611011576040517f624238f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461103957600080fd5b919050565b60008083601f84011261105057600080fd5b50813567ffffffffffffffff81111561106857600080fd5b60208301915083602082850101111561108057600080fd5b9250929050565b60008060008060006060868803121561109f57600080fd5b853567ffffffffffffffff808211156110b757600080fd5b818801915088601f8301126110cb57600080fd5b8135818111156110da57600080fd5b8960208260051b85010111156110ef57600080fd5b6020830197508096505061110560208901611015565b9450604088013591508082111561111b57600080fd5b506111288882890161103e565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561118b5761118b611139565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111d8576111d8611139565b604052919050565b600067ffffffffffffffff8211156111fa576111fa611139565b5060051b60200190565b6000611217611212846111e0565b611191565b83815260208082019190600586811b86013681111561123557600080fd5b865b8181101561135357803567ffffffffffffffff808211156112585760008081fd5b818a0191506060823603121561126e5760008081fd5b611276611168565b61127f83611015565b815286830135600381106112935760008081fd5b81880152604083810135838111156112ab5760008081fd5b939093019236601f8501126112c257600092508283fd5b833592506112d2611212846111e0565b83815292871b840188019288810190368511156112ef5760008081fd5b948901945b8486101561133c5785357fffffffff000000000000000000000000000000000000000000000000000000008116811461132d5760008081fd5b825294890194908901906112f4565b918301919091525088525050948301948301611237565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60005b838110156113d95781810151838201526020016113c1565b50506000910152565b600081518084526113fa8160208601602086016113be565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301606084528087518083526080925060808601915060808160051b8701016020808b0160005b8481101561155a577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff825116865284820151600381106114e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156115455783517fffffffff00000000000000000000000000000000000000000000000000000000168252928601926001929092019190860190611503565b50978501979550505090820190600101611458565b505073ffffffffffffffffffffffffffffffffffffffff8a1690880152868103604088015261158981896113e2565b9a9950505050505050505050565b600082516115a98184602087016113be565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006115e260408301846113e2565b949350505050565b81810381811115611624577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220df8ab2265a459658abd2e76c3043dd9d6dcf8c65ce20438c29be6dc968c1336464736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004611087565b610045565b005b61004d61009e565b61009761005a8587611204565b8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061015692505050565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff163314610154577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546040517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201523360248201526044015b60405180910390fd5b565b60005b83518110156102ec57600084828151811061017657610176611360565b6020026020010151602001519050600060028111156101975761019761138f565b8160028111156101a9576101a961138f565b036101f7576101f28583815181106101c3576101c3611360565b6020026020010151600001518684815181106101e1576101e1611360565b602002602001015160400151610337565b6102e3565b600181600281111561020b5761020b61138f565b03610254576101f285838151811061022557610225611360565b60200260200101516000015186848151811061024357610243611360565b6020026020010151604001516105d0565b60028160028111156102685761026861138f565b036102b1576101f285838151811061028257610282611360565b6020026020010151600001518684815181106102a0576102a0611360565b602002602001015160400151610879565b6040517fdb62f38a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600101610159565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103209392919061142c565b60405180910390a161033282826109b5565b505050565b8051600003610372576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff83166103e0576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff82169003610428576104288285610a95565b60005b835181101561009757600084828151811061044857610448611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff1680156104d7576040517ffbdfc64e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff00000000000000000000000000000000000000001617905550506001918201910161042b565b805160000361060b576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff8316610679576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff821690036106c1576106c18285610a95565b60005b83518110156100975760008482815181106106e1576106e1611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff9081169087168103610775576040517fb4a10fbb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610780858284610b0b565b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff0000000000000000000000000000000000000000161790555050600191820191016106c4565b80516000036108b4576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff831615610923576040517f9d78f07d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82518110156109af57600083828151811061094357610943611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff166109a5848284610b0b565b5050600101610926565b50505050565b73ffffffffffffffffffffffffffffffffffffffff82166109d4575050565b6109dd82610fd4565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610a059190611597565b600060405180830381855af49150503d8060008114610a40576040519150601f19603f3d011682016040523d82523d6000602084013e610a45565b606091505b5091509150816109af57805115610a5f5780518082602001fd5b83836040517f4ecac2bb00000000000000000000000000000000000000000000000000000000815260040161014b9291906115b3565b610a9e81610fd4565b60028201805473ffffffffffffffffffffffffffffffffffffffff90921660008181526001948501602090815260408220860185905594840183559182529290200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169091179055565b73ffffffffffffffffffffffffffffffffffffffff8216610b58576040517f5e9bd5a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff831603610ba7576040517ff12e329600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081166000908152602084815260408083205473ffffffffffffffffffffffffffffffffffffffff86168452600180880190935290832054740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff169291610c31916115ea565b9050808214610d785773ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260408120805483908110610c7357610c73611360565b6000918252602080832060088304015473ffffffffffffffffffffffffffffffffffffffff8916845260018a019091526040909220805460079092166004026101000a90920460e01b925082919085908110610cd157610cd1611360565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790557fffffffff0000000000000000000000000000000000000000000000000000000092909216825286905260409020805473ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000006bffffffffffffffffffffffff8516021790555b73ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260409020805480610dae57610dae61162a565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff000000000000000000000000000000000000000000000000000000008516825286905260408120819055819003610097576002850154600090610e47906001906115ea565b73ffffffffffffffffffffffffffffffffffffffff86166000908152600180890160205260409091200154909150808214610f35576000876002018381548110610e9357610e93611360565b60009182526020909120015460028901805473ffffffffffffffffffffffffffffffffffffffff9092169250829184908110610ed157610ed1611360565b600091825260208083209190910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff948516179055929091168152600189810190925260409020018190555b86600201805480610f4857610f4861162a565b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905590920190925573ffffffffffffffffffffffffffffffffffffffff88168252600189810190915260408220015550505050505050565b803b6000819003611011576040517f624238f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461103957600080fd5b919050565b60008083601f84011261105057600080fd5b50813567ffffffffffffffff81111561106857600080fd5b60208301915083602082850101111561108057600080fd5b9250929050565b60008060008060006060868803121561109f57600080fd5b853567ffffffffffffffff808211156110b757600080fd5b818801915088601f8301126110cb57600080fd5b8135818111156110da57600080fd5b8960208260051b85010111156110ef57600080fd5b6020830197508096505061110560208901611015565b9450604088013591508082111561111b57600080fd5b506111288882890161103e565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561118b5761118b611139565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111d8576111d8611139565b604052919050565b600067ffffffffffffffff8211156111fa576111fa611139565b5060051b60200190565b6000611217611212846111e0565b611191565b83815260208082019190600586811b86013681111561123557600080fd5b865b8181101561135357803567ffffffffffffffff808211156112585760008081fd5b818a0191506060823603121561126e5760008081fd5b611276611168565b61127f83611015565b815286830135600381106112935760008081fd5b81880152604083810135838111156112ab5760008081fd5b939093019236601f8501126112c257600092508283fd5b833592506112d2611212846111e0565b83815292871b840188019288810190368511156112ef5760008081fd5b948901945b8486101561133c5785357fffffffff000000000000000000000000000000000000000000000000000000008116811461132d5760008081fd5b825294890194908901906112f4565b918301919091525088525050948301948301611237565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60005b838110156113d95781810151838201526020016113c1565b50506000910152565b600081518084526113fa8160208601602086016113be565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301606084528087518083526080925060808601915060808160051b8701016020808b0160005b8481101561155a577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff825116865284820151600381106114e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156115455783517fffffffff00000000000000000000000000000000000000000000000000000000168252928601926001929092019190860190611503565b50978501979550505090820190600101611458565b505073ffffffffffffffffffffffffffffffffffffffff8a1690880152868103604088015261158981896113e2565b9a9950505050505050505050565b600082516115a98184602087016113be565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006115e260408301846113e2565b949350505050565b81810381811115611624577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220df8ab2265a459658abd2e76c3043dd9d6dcf8c65ce20438c29be6dc968c1336464736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0xDE9F15dc22946BAC9D90Be1116609e5f622E5201" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "DiamondCutFacet", + "sourceName": "contracts/facets/DiamondCutFacet.sol", + "abi": [ + { + "inputs": [], + "name": "LibDiamond__AddressMustBeZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__FunctionAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__ImmutableFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__IncorrectAction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFacetCode", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LibDiamond__InitializationFailed", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidAddressZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidReplacementWithSameFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__NoSelectors", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_cut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_cut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b5061168f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004611087565b610045565b005b61004d61009e565b61009761005a8587611204565b8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061015692505050565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff163314610154577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546040517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201523360248201526044015b60405180910390fd5b565b60005b83518110156102ec57600084828151811061017657610176611360565b6020026020010151602001519050600060028111156101975761019761138f565b8160028111156101a9576101a961138f565b036101f7576101f28583815181106101c3576101c3611360565b6020026020010151600001518684815181106101e1576101e1611360565b602002602001015160400151610337565b6102e3565b600181600281111561020b5761020b61138f565b03610254576101f285838151811061022557610225611360565b60200260200101516000015186848151811061024357610243611360565b6020026020010151604001516105d0565b60028160028111156102685761026861138f565b036102b1576101f285838151811061028257610282611360565b6020026020010151600001518684815181106102a0576102a0611360565b602002602001015160400151610879565b6040517fdb62f38a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600101610159565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103209392919061142c565b60405180910390a161033282826109b5565b505050565b8051600003610372576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff83166103e0576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff82169003610428576104288285610a95565b60005b835181101561009757600084828151811061044857610448611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff1680156104d7576040517ffbdfc64e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff00000000000000000000000000000000000000001617905550506001918201910161042b565b805160000361060b576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff8316610679576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff821690036106c1576106c18285610a95565b60005b83518110156100975760008482815181106106e1576106e1611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff9081169087168103610775576040517fb4a10fbb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610780858284610b0b565b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff0000000000000000000000000000000000000000161790555050600191820191016106c4565b80516000036108b4576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff831615610923576040517f9d78f07d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82518110156109af57600083828151811061094357610943611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff166109a5848284610b0b565b5050600101610926565b50505050565b73ffffffffffffffffffffffffffffffffffffffff82166109d4575050565b6109dd82610fd4565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610a059190611597565b600060405180830381855af49150503d8060008114610a40576040519150601f19603f3d011682016040523d82523d6000602084013e610a45565b606091505b5091509150816109af57805115610a5f5780518082602001fd5b83836040517f4ecac2bb00000000000000000000000000000000000000000000000000000000815260040161014b9291906115b3565b610a9e81610fd4565b60028201805473ffffffffffffffffffffffffffffffffffffffff90921660008181526001948501602090815260408220860185905594840183559182529290200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169091179055565b73ffffffffffffffffffffffffffffffffffffffff8216610b58576040517f5e9bd5a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff831603610ba7576040517ff12e329600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081166000908152602084815260408083205473ffffffffffffffffffffffffffffffffffffffff86168452600180880190935290832054740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff169291610c31916115ea565b9050808214610d785773ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260408120805483908110610c7357610c73611360565b6000918252602080832060088304015473ffffffffffffffffffffffffffffffffffffffff8916845260018a019091526040909220805460079092166004026101000a90920460e01b925082919085908110610cd157610cd1611360565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790557fffffffff0000000000000000000000000000000000000000000000000000000092909216825286905260409020805473ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000006bffffffffffffffffffffffff8516021790555b73ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260409020805480610dae57610dae61162a565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff000000000000000000000000000000000000000000000000000000008516825286905260408120819055819003610097576002850154600090610e47906001906115ea565b73ffffffffffffffffffffffffffffffffffffffff86166000908152600180890160205260409091200154909150808214610f35576000876002018381548110610e9357610e93611360565b60009182526020909120015460028901805473ffffffffffffffffffffffffffffffffffffffff9092169250829184908110610ed157610ed1611360565b600091825260208083209190910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff948516179055929091168152600189810190925260409020018190555b86600201805480610f4857610f4861162a565b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905590920190925573ffffffffffffffffffffffffffffffffffffffff88168252600189810190915260408220015550505050505050565b803b6000819003611011576040517f624238f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461103957600080fd5b919050565b60008083601f84011261105057600080fd5b50813567ffffffffffffffff81111561106857600080fd5b60208301915083602082850101111561108057600080fd5b9250929050565b60008060008060006060868803121561109f57600080fd5b853567ffffffffffffffff808211156110b757600080fd5b818801915088601f8301126110cb57600080fd5b8135818111156110da57600080fd5b8960208260051b85010111156110ef57600080fd5b6020830197508096505061110560208901611015565b9450604088013591508082111561111b57600080fd5b506111288882890161103e565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561118b5761118b611139565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111d8576111d8611139565b604052919050565b600067ffffffffffffffff8211156111fa576111fa611139565b5060051b60200190565b6000611217611212846111e0565b611191565b83815260208082019190600586811b86013681111561123557600080fd5b865b8181101561135357803567ffffffffffffffff808211156112585760008081fd5b818a0191506060823603121561126e5760008081fd5b611276611168565b61127f83611015565b815286830135600381106112935760008081fd5b81880152604083810135838111156112ab5760008081fd5b939093019236601f8501126112c257600092508283fd5b833592506112d2611212846111e0565b83815292871b840188019288810190368511156112ef5760008081fd5b948901945b8486101561133c5785357fffffffff000000000000000000000000000000000000000000000000000000008116811461132d5760008081fd5b825294890194908901906112f4565b918301919091525088525050948301948301611237565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60005b838110156113d95781810151838201526020016113c1565b50506000910152565b600081518084526113fa8160208601602086016113be565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301606084528087518083526080925060808601915060808160051b8701016020808b0160005b8481101561155a577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff825116865284820151600381106114e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156115455783517fffffffff00000000000000000000000000000000000000000000000000000000168252928601926001929092019190860190611503565b50978501979550505090820190600101611458565b505073ffffffffffffffffffffffffffffffffffffffff8a1690880152868103604088015261158981896113e2565b9a9950505050505050505050565b600082516115a98184602087016113be565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006115e260408301846113e2565b949350505050565b81810381811115611624577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220df8ab2265a459658abd2e76c3043dd9d6dcf8c65ce20438c29be6dc968c1336464736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004611087565b610045565b005b61004d61009e565b61009761005a8587611204565b8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061015692505050565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff163314610154577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546040517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201523360248201526044015b60405180910390fd5b565b60005b83518110156102ec57600084828151811061017657610176611360565b6020026020010151602001519050600060028111156101975761019761138f565b8160028111156101a9576101a961138f565b036101f7576101f28583815181106101c3576101c3611360565b6020026020010151600001518684815181106101e1576101e1611360565b602002602001015160400151610337565b6102e3565b600181600281111561020b5761020b61138f565b03610254576101f285838151811061022557610225611360565b60200260200101516000015186848151811061024357610243611360565b6020026020010151604001516105d0565b60028160028111156102685761026861138f565b036102b1576101f285838151811061028257610282611360565b6020026020010151600001518684815181106102a0576102a0611360565b602002602001015160400151610879565b6040517fdb62f38a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600101610159565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103209392919061142c565b60405180910390a161033282826109b5565b505050565b8051600003610372576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff83166103e0576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff82169003610428576104288285610a95565b60005b835181101561009757600084828151811061044857610448611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff1680156104d7576040517ffbdfc64e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff00000000000000000000000000000000000000001617905550506001918201910161042b565b805160000361060b576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff8316610679576040517f3ee3364a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600182016020526040812054906bffffffffffffffffffffffff821690036106c1576106c18285610a95565b60005b83518110156100975760008482815181106106e1576106e1611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff9081169087168103610775576040517fb4a10fbb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610780858284610b0b565b7fffffffff000000000000000000000000000000000000000000000000000000008216600081815260208781526040808320805473ffffffffffffffffffffffffffffffffffffffff908116740100000000000000000000000000000000000000006bffffffffffffffffffffffff8c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281547fffffffffffffffffffffffff0000000000000000000000000000000000000000161790555050600191820191016106c4565b80516000036108b4576040517fde59c25100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff831615610923576040517f9d78f07d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82518110156109af57600083828151811061094357610943611360565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff166109a5848284610b0b565b5050600101610926565b50505050565b73ffffffffffffffffffffffffffffffffffffffff82166109d4575050565b6109dd82610fd4565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610a059190611597565b600060405180830381855af49150503d8060008114610a40576040519150601f19603f3d011682016040523d82523d6000602084013e610a45565b606091505b5091509150816109af57805115610a5f5780518082602001fd5b83836040517f4ecac2bb00000000000000000000000000000000000000000000000000000000815260040161014b9291906115b3565b610a9e81610fd4565b60028201805473ffffffffffffffffffffffffffffffffffffffff90921660008181526001948501602090815260408220860185905594840183559182529290200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169091179055565b73ffffffffffffffffffffffffffffffffffffffff8216610b58576040517f5e9bd5a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff831603610ba7576040517ff12e329600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081166000908152602084815260408083205473ffffffffffffffffffffffffffffffffffffffff86168452600180880190935290832054740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff169291610c31916115ea565b9050808214610d785773ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260408120805483908110610c7357610c73611360565b6000918252602080832060088304015473ffffffffffffffffffffffffffffffffffffffff8916845260018a019091526040909220805460079092166004026101000a90920460e01b925082919085908110610cd157610cd1611360565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790557fffffffff0000000000000000000000000000000000000000000000000000000092909216825286905260409020805473ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000006bffffffffffffffffffffffff8516021790555b73ffffffffffffffffffffffffffffffffffffffff841660009081526001860160205260409020805480610dae57610dae61162a565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff000000000000000000000000000000000000000000000000000000008516825286905260408120819055819003610097576002850154600090610e47906001906115ea565b73ffffffffffffffffffffffffffffffffffffffff86166000908152600180890160205260409091200154909150808214610f35576000876002018381548110610e9357610e93611360565b60009182526020909120015460028901805473ffffffffffffffffffffffffffffffffffffffff9092169250829184908110610ed157610ed1611360565b600091825260208083209190910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff948516179055929091168152600189810190925260409020018190555b86600201805480610f4857610f4861162a565b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905590920190925573ffffffffffffffffffffffffffffffffffffffff88168252600189810190915260408220015550505050505050565b803b6000819003611011576040517f624238f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461103957600080fd5b919050565b60008083601f84011261105057600080fd5b50813567ffffffffffffffff81111561106857600080fd5b60208301915083602082850101111561108057600080fd5b9250929050565b60008060008060006060868803121561109f57600080fd5b853567ffffffffffffffff808211156110b757600080fd5b818801915088601f8301126110cb57600080fd5b8135818111156110da57600080fd5b8960208260051b85010111156110ef57600080fd5b6020830197508096505061110560208901611015565b9450604088013591508082111561111b57600080fd5b506111288882890161103e565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561118b5761118b611139565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111d8576111d8611139565b604052919050565b600067ffffffffffffffff8211156111fa576111fa611139565b5060051b60200190565b6000611217611212846111e0565b611191565b83815260208082019190600586811b86013681111561123557600080fd5b865b8181101561135357803567ffffffffffffffff808211156112585760008081fd5b818a0191506060823603121561126e5760008081fd5b611276611168565b61127f83611015565b815286830135600381106112935760008081fd5b81880152604083810135838111156112ab5760008081fd5b939093019236601f8501126112c257600092508283fd5b833592506112d2611212846111e0565b83815292871b840188019288810190368511156112ef5760008081fd5b948901945b8486101561133c5785357fffffffff000000000000000000000000000000000000000000000000000000008116811461132d5760008081fd5b825294890194908901906112f4565b918301919091525088525050948301948301611237565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60005b838110156113d95781810151838201526020016113c1565b50506000910152565b600081518084526113fa8160208601602086016113be565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301606084528087518083526080925060808601915060808160051b8701016020808b0160005b8481101561155a577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff825116865284820151600381106114e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156115455783517fffffffff00000000000000000000000000000000000000000000000000000000168252928601926001929092019190860190611503565b50978501979550505090820190600101611458565b505073ffffffffffffffffffffffffffffffffffffffff8a1690880152868103604088015261158981896113e2565b9a9950505050505050505050565b600082516115a98184602087016113be565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006115e260408301846113e2565b949350505050565b81810381811115611624577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220df8ab2265a459658abd2e76c3043dd9d6dcf8c65ce20438c29be6dc968c1336464736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x10bbD18FcB1d98aA0F943c01176f2BE4E7c8B782" + } +} \ No newline at end of file diff --git a/deployments/DiamondInit.json b/deployments/DiamondInit.json new file mode 100644 index 0000000..9e8a4bf --- /dev/null +++ b/deployments/DiamondInit.json @@ -0,0 +1,234 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "DiamondInit", + "sourceName": "contracts/upgradeInitializers/DiamondInit.sol", + "abi": [ + { + "inputs": [], + "name": "DiamondInit__WrongDeploymentArguments", + "type": "error" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "routerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "factoryAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stratosphereAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "vaporDexAggregator", + "type": "address" + }, + { + "internalType": "address", + "name": "vaporDexAdapter", + "type": "address" + }, + { + "internalType": "address", + "name": "usdc", + "type": "address" + }, + { + "internalType": "address", + "name": "vape", + "type": "address" + }, + { + "internalType": "address", + "name": "weth", + "type": "address" + }, + { + "internalType": "uint256", + "name": "launchFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minLiquidityETH", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "minLockDuration", + "type": "uint40" + }, + { + "internalType": "address", + "name": "sablier", + "type": "address" + }, + { + "internalType": "address", + "name": "nonFungiblePositionManager", + "type": "address" + }, + { + "internalType": "address", + "name": "teamMultisig", + "type": "address" + }, + { + "internalType": "uint256", + "name": "slippage", + "type": "uint256" + } + ], + "internalType": "struct DiamondInit.DeployArgs", + "name": "_args", + "type": "tuple" + } + ], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506106538061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638d76b8ef14610030575b600080fd5b61004361003e36600461050e565b610045565b005b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f6020527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790557f7f5828d0000000000000000000000000000000000000000000000000000000006000527f5622121b47b8cd0120c4efe45dd5483242f54a3d49bd7679be565d47694918c38054909116909117905580517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff1615806101b65750604082015173ffffffffffffffffffffffffffffffffffffffff16155b806101d95750606082015173ffffffffffffffffffffffffffffffffffffffff16155b806101fc5750608082015173ffffffffffffffffffffffffffffffffffffffff16155b8061021f575060a082015173ffffffffffffffffffffffffffffffffffffffff16155b8061022d5750610100820151155b80610251575061016082015173ffffffffffffffffffffffffffffffffffffffff16155b8061025f5750610120820151155b80610274575061014082015164ffffffffff16155b80610297575060e082015173ffffffffffffffffffffffffffffffffffffffff16155b806102bb575061018082015173ffffffffffffffffffffffffffffffffffffffff16155b806102df57506101a082015173ffffffffffffffffffffffffffffffffffffffff16155b15610316576040517fa62246b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508051600280547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff93841617909155602083015160018054831691841691909117905560408301516003805483169184169190911790556060830151600480548316918416919091179055608083015160058054831691841691909117905560a083015160068054831691841691909117905560c083015160078054831691841691909117905560e0830151600880548316918416919091179055610100830151600c55610120830151600d55610140830151601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff909216919091179055610160830151600980548316918416919091179055610180830151600a805483169184169190911790556101a0830151600b805490921692169190911790556101c00151600e55565b6040516101e0810167ffffffffffffffff811182821017156104ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b803573ffffffffffffffffffffffffffffffffffffffff811681146104f457600080fd5b919050565b803564ffffffffff811681146104f457600080fd5b60006101e0828403121561052157600080fd5b61052961047f565b610532836104d0565b8152610540602084016104d0565b6020820152610551604084016104d0565b6040820152610562606084016104d0565b6060820152610573608084016104d0565b608082015261058460a084016104d0565b60a082015261059560c084016104d0565b60c08201526105a660e084016104d0565b60e0820152610100838101359082015261012080840135908201526101406105cf8185016104f9565b908201526101606105e18482016104d0565b908201526101806105f38482016104d0565b908201526101a06106058482016104d0565b908201526101c092830135928101929092525091905056fea264697066735822122080e6d210cf3c628d3daa486412f1d7ac694a76837280984ce4514f407c24e71a64736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80638d76b8ef14610030575b600080fd5b61004361003e36600461050e565b610045565b005b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f6020527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790557f7f5828d0000000000000000000000000000000000000000000000000000000006000527f5622121b47b8cd0120c4efe45dd5483242f54a3d49bd7679be565d47694918c38054909116909117905580517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff1615806101b65750604082015173ffffffffffffffffffffffffffffffffffffffff16155b806101d95750606082015173ffffffffffffffffffffffffffffffffffffffff16155b806101fc5750608082015173ffffffffffffffffffffffffffffffffffffffff16155b8061021f575060a082015173ffffffffffffffffffffffffffffffffffffffff16155b8061022d5750610100820151155b80610251575061016082015173ffffffffffffffffffffffffffffffffffffffff16155b8061025f5750610120820151155b80610274575061014082015164ffffffffff16155b80610297575060e082015173ffffffffffffffffffffffffffffffffffffffff16155b806102bb575061018082015173ffffffffffffffffffffffffffffffffffffffff16155b806102df57506101a082015173ffffffffffffffffffffffffffffffffffffffff16155b15610316576040517fa62246b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508051600280547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff93841617909155602083015160018054831691841691909117905560408301516003805483169184169190911790556060830151600480548316918416919091179055608083015160058054831691841691909117905560a083015160068054831691841691909117905560c083015160078054831691841691909117905560e0830151600880548316918416919091179055610100830151600c55610120830151600d55610140830151601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff909216919091179055610160830151600980548316918416919091179055610180830151600a805483169184169190911790556101a0830151600b805490921692169190911790556101c00151600e55565b6040516101e0810167ffffffffffffffff811182821017156104ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b803573ffffffffffffffffffffffffffffffffffffffff811681146104f457600080fd5b919050565b803564ffffffffff811681146104f457600080fd5b60006101e0828403121561052157600080fd5b61052961047f565b610532836104d0565b8152610540602084016104d0565b6020820152610551604084016104d0565b6040820152610562606084016104d0565b6060820152610573608084016104d0565b608082015261058460a084016104d0565b60a082015261059560c084016104d0565b60c08201526105a660e084016104d0565b60e0820152610100838101359082015261012080840135908201526101406105cf8185016104f9565b908201526101606105e18482016104d0565b908201526101806105f38482016104d0565b908201526101a06106058482016104d0565b908201526101c092830135928101929092525091905056fea264697066735822122080e6d210cf3c628d3daa486412f1d7ac694a76837280984ce4514f407c24e71a64736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x86615becFBEccFe7D13dEEc8e0e8C287A5182cF7" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "DiamondInit", + "sourceName": "contracts/upgradeInitializers/DiamondInit.sol", + "abi": [ + { + "inputs": [], + "name": "DiamondInit__WrongDeploymentArguments", + "type": "error" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "routerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "factoryAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stratosphereAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "vaporDexAggregator", + "type": "address" + }, + { + "internalType": "address", + "name": "vaporDexAdapter", + "type": "address" + }, + { + "internalType": "address", + "name": "usdc", + "type": "address" + }, + { + "internalType": "address", + "name": "vape", + "type": "address" + }, + { + "internalType": "address", + "name": "weth", + "type": "address" + }, + { + "internalType": "uint256", + "name": "launchFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minLiquidityETH", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "minLockDuration", + "type": "uint40" + }, + { + "internalType": "address", + "name": "sablier", + "type": "address" + }, + { + "internalType": "address", + "name": "nonFungiblePositionManager", + "type": "address" + }, + { + "internalType": "address", + "name": "teamMultisig", + "type": "address" + }, + { + "internalType": "uint256", + "name": "slippage", + "type": "uint256" + } + ], + "internalType": "struct DiamondInit.DeployArgs", + "name": "_args", + "type": "tuple" + } + ], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506106538061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638d76b8ef14610030575b600080fd5b61004361003e36600461050e565b610045565b005b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f6020527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790557f7f5828d0000000000000000000000000000000000000000000000000000000006000527f5622121b47b8cd0120c4efe45dd5483242f54a3d49bd7679be565d47694918c38054909116909117905580517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff1615806101b65750604082015173ffffffffffffffffffffffffffffffffffffffff16155b806101d95750606082015173ffffffffffffffffffffffffffffffffffffffff16155b806101fc5750608082015173ffffffffffffffffffffffffffffffffffffffff16155b8061021f575060a082015173ffffffffffffffffffffffffffffffffffffffff16155b8061022d5750610100820151155b80610251575061016082015173ffffffffffffffffffffffffffffffffffffffff16155b8061025f5750610120820151155b80610274575061014082015164ffffffffff16155b80610297575060e082015173ffffffffffffffffffffffffffffffffffffffff16155b806102bb575061018082015173ffffffffffffffffffffffffffffffffffffffff16155b806102df57506101a082015173ffffffffffffffffffffffffffffffffffffffff16155b15610316576040517fa62246b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508051600280547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff93841617909155602083015160018054831691841691909117905560408301516003805483169184169190911790556060830151600480548316918416919091179055608083015160058054831691841691909117905560a083015160068054831691841691909117905560c083015160078054831691841691909117905560e0830151600880548316918416919091179055610100830151600c55610120830151600d55610140830151601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff909216919091179055610160830151600980548316918416919091179055610180830151600a805483169184169190911790556101a0830151600b805490921692169190911790556101c00151600e55565b6040516101e0810167ffffffffffffffff811182821017156104ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b803573ffffffffffffffffffffffffffffffffffffffff811681146104f457600080fd5b919050565b803564ffffffffff811681146104f457600080fd5b60006101e0828403121561052157600080fd5b61052961047f565b610532836104d0565b8152610540602084016104d0565b6020820152610551604084016104d0565b6040820152610562606084016104d0565b6060820152610573608084016104d0565b608082015261058460a084016104d0565b60a082015261059560c084016104d0565b60c08201526105a660e084016104d0565b60e0820152610100838101359082015261012080840135908201526101406105cf8185016104f9565b908201526101606105e18482016104d0565b908201526101806105f38482016104d0565b908201526101a06106058482016104d0565b908201526101c092830135928101929092525091905056fea264697066735822122080e6d210cf3c628d3daa486412f1d7ac694a76837280984ce4514f407c24e71a64736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80638d76b8ef14610030575b600080fd5b61004361003e36600461050e565b610045565b005b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f6020527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790557f7f5828d0000000000000000000000000000000000000000000000000000000006000527f5622121b47b8cd0120c4efe45dd5483242f54a3d49bd7679be565d47694918c38054909116909117905580517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff1615806101b65750604082015173ffffffffffffffffffffffffffffffffffffffff16155b806101d95750606082015173ffffffffffffffffffffffffffffffffffffffff16155b806101fc5750608082015173ffffffffffffffffffffffffffffffffffffffff16155b8061021f575060a082015173ffffffffffffffffffffffffffffffffffffffff16155b8061022d5750610100820151155b80610251575061016082015173ffffffffffffffffffffffffffffffffffffffff16155b8061025f5750610120820151155b80610274575061014082015164ffffffffff16155b80610297575060e082015173ffffffffffffffffffffffffffffffffffffffff16155b806102bb575061018082015173ffffffffffffffffffffffffffffffffffffffff16155b806102df57506101a082015173ffffffffffffffffffffffffffffffffffffffff16155b15610316576040517fa62246b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508051600280547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff93841617909155602083015160018054831691841691909117905560408301516003805483169184169190911790556060830151600480548316918416919091179055608083015160058054831691841691909117905560a083015160068054831691841691909117905560c083015160078054831691841691909117905560e0830151600880548316918416919091179055610100830151600c55610120830151600d55610140830151601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff909216919091179055610160830151600980548316918416919091179055610180830151600a805483169184169190911790556101a0830151600b805490921692169190911790556101c00151600e55565b6040516101e0810167ffffffffffffffff811182821017156104ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b803573ffffffffffffffffffffffffffffffffffffffff811681146104f457600080fd5b919050565b803564ffffffffff811681146104f457600080fd5b60006101e0828403121561052157600080fd5b61052961047f565b610532836104d0565b8152610540602084016104d0565b6020820152610551604084016104d0565b6040820152610562606084016104d0565b6060820152610573608084016104d0565b608082015261058460a084016104d0565b60a082015261059560c084016104d0565b60c08201526105a660e084016104d0565b60e0820152610100838101359082015261012080840135908201526101406105cf8185016104f9565b908201526101606105e18482016104d0565b908201526101806105f38482016104d0565b908201526101a06106058482016104d0565b908201526101c092830135928101929092525091905056fea264697066735822122080e6d210cf3c628d3daa486412f1d7ac694a76837280984ce4514f407c24e71a64736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x8655d39A9E14B3458E68d9792E0e01a054ad384c" + } +} \ No newline at end of file diff --git a/deployments/LaunchERC20Facet.json b/deployments/LaunchERC20Facet.json new file mode 100644 index 0000000..74a22c5 --- /dev/null +++ b/deployments/LaunchERC20Facet.json @@ -0,0 +1,450 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "LaunchERC20Facet", + "sourceName": "contracts/facets/LaunchERC20Facet.sol", + "abi": [ + { + "inputs": [], + "name": "LaunchERC20Facet__InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__MinimumLockDuration", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__NotEnoughLiquidity", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + } + ], + "name": "LaunchERC20Facet__TranferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__WrongLaunchArguments", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pair", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_burner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "LiquidityBurned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_pairAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "LiquidityTokensUnlocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_pairAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "LiquidityTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_streamId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_pair", + "type": "address" + } + ], + "name": "StreamCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_creatorAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_streamId", + "type": "uint256" + } + ], + "name": "TokenLaunched", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_tradingStartsAt", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "lockDuration", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "_burnLiquidity", + "type": "bool" + } + ], + "name": "launchERC20", + "outputs": [ + { + "internalType": "address", + "name": "_pair", + "type": "address" + }, + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b5061454a8061001f6000396000f3fe60806040526004361061001e5760003560e01c80636c20eebb14610023575b600080fd5b6100366100313660046116d5565b61006d565b6040805173ffffffffffffffffffffffffffffffffffffffff94851681529390921660208401529082015260600160405180910390f35b600080600080600d01543410156100b0576040517f5b35740900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100b933610c40565b6004546005546100ea918b918b918b918b9173ffffffffffffffffffffffffffffffffffffffff9081169116610e11565b6001546008546040517fc9c6539600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808516600483015291821660248201529294508492911690819063c9c65396906044016020604051808303816000875af115801561016d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019191906117a5565b6002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018c905291965083169063095ea7b3906044016020604051808303816000875af115801561020c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023091906117c0565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018b905283169063095ea7b3906044016020604051808303816000875af11580156102a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ca91906117c0565b5060025473ffffffffffffffffffffffffffffffffffffffff168063f305d71934878d8083306102fc42610258611813565b60405160e089901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff9687166004820152602481019590955260448501939093526064840191909152909216608482015260a481019190915260c40160606040518083038185885af115801561038e573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906103b39190611826565b50506008546040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529182166024820152908416915063e6a4390590604401602060405180830381865afa15801561042e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045291906117a5565b955073ffffffffffffffffffffffffffffffffffffffff86166104a1576040517f9272223e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f0187702000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152841690630187702090602401600060405180830381600087803b15801561050a57600080fd5b505af115801561051e573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663715018a66040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b508892505088159050610785576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063a9059cbb9060009083906370a0823190602401602060405180830381865afa158015610600573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106249190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af1158015610694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b891906117c0565b506040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152339073ffffffffffffffffffffffffffffffffffffffff898116917fd289537cc1c5d4ce83b387cec5cdc2658a741cf986d6ad8521af47b377be7ef6918516906370a0823190602401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f9190611854565b60405190815260200160405180910390a3610b84565b60105464ffffffffff908116908a1610156107cc576040517fe47f9cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381169263095ea7b39291169083906370a0823190602401602060405180830381865afa158015610845573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108699190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af11580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd91906117c0565b50610960604080516101008101825260008082526020808301829052828401829052606083018290526080830182905260a083018290528351808501855282815280820183905260c084015283518085019094528184528301529060e082015290565b308082523360208301526040517f70a08231000000000000000000000000000000000000000000000000000000008152600481019190915273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156109d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fa9190611854565b6fffffffffffffffffffffffffffffffff1660408083019190915273ffffffffffffffffffffffffffffffffffffffff8316606083015260006080830152600160a0830181905281518083019092528190610a588d6201518061186d565b610a629190611896565b64ffffffffff168152602001610a7b8c6201518061186d565b64ffffffffff16905260c08201526009546040517fab167ccc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063ab167ccc90610adf9084906004016118bb565b6020604051808303816000875af1158015610afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b229190611854565b33600081815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8d811685529252808320859055519399508b169289917f39679ae33cd13645ec63a701454bd16e6beb24116d89b21c45edb2647cf0bd2e91a4505b600c54610b9c90610b9790600290611996565b610ed6565b610ba4611150565b336000818152601160209081526040808320805460018101825590845291832090910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8b1690811790915590518893927f1a780177e5001bb4f067da390710f31a74a35b48fe52f49d5b60e854744f115491a45050505096509650969350505050565b600654600c546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529092169182906370a0823190602401602060405180830381865afa158015610cb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd99190611854565b1015610d11576040517f09785c3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015230602483015260448201929092526000918316906323b872dd906064016020604051808303816000875af1158015610d93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db791906117c0565b905080610e0c576040517f4611cd5800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240160405180910390fd5b505050565b6000841580610e2b5750610e28426202a300611813565b84105b15610e62576040517f3fbfb3d200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868686600060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163088888833604051610e9c90611582565b610eae99989796959493929190611a35565b604051809103906000f080158015610eca573d6000803e3d6000fd5b50979650505050505050565b600654600480546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821692810192909252602482018490529091169063095ea7b3906044016020604051808303816000875af1158015610f55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7991906117c0565b50600480546006546007546040517f4c09cf4e00000000000000000000000000000000000000000000000000000000815293840185905273ffffffffffffffffffffffffffffffffffffffff91821660248501528116604484015260016064840152600092911690634c09cf4e90608401600060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261104d9190810190611b4d565b905061107a6040518060800160405280600081526020016000815260200160608152602001606081525090565b8281528151805161108d90600190611c62565b8151811061109d5761109d611c75565b60209081029190910181015182820152604080840151818401529083015160608301526004805491517f6bf2df8600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90921691636bf2df8691611119918591309160009101611cf6565b600060405180830381600087803b15801561113357600080fd5b505af1158015611147573d6000803e3d6000fd5b50505050505050565b6006546007546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff928316929091169060009083906370a0823190602401602060405180830381865afa1580156111ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ee9190611854565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa15801561125e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112829190611854565b600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810185905291925085169063095ea7b3906044016020604051808303816000875af11580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132191906117c0565b50600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390529084169063095ea7b3906044016020604051808303816000875af115801561139b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bf91906117c0565b5060006040518061016001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001610bb862ffffff1681526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c60020b8152602001620d89b460020b8152602001838152602001848152602001611463846000600e0154611560565b61146d9085611c62565b8152602001611481856000600e0154611560565b61148b9086611c62565b8152600b5473ffffffffffffffffffffffffffffffffffffffff1660208201526040016114b9426078611813565b9052600a546040517f8831645600000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff1690638831645690611512908490600401611d8b565b6080604051808303816000875af1158015611531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115559190611e76565b505050505050505050565b600061271061156f8385611ec9565b6115799190611996565b90505b92915050565b61263480611ee183390190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516080810167ffffffffffffffff811182821017156115e1576115e161158f565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561162e5761162e61158f565b604052919050565b600082601f83011261164757600080fd5b813567ffffffffffffffff8111156116615761166161158f565b61169260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016115e7565b8181528460208386010111156116a757600080fd5b816020850160208301376000918101602001919091529392505050565b80151581146116d257600080fd5b50565b60008060008060008060c087890312156116ee57600080fd5b863567ffffffffffffffff8082111561170657600080fd5b6117128a838b01611636565b9750602089013591508082111561172857600080fd5b5061173589828a01611636565b9550506040870135935060608701359250608087013564ffffffffff8116811461175e57600080fd5b915060a087013561176e816116c4565b809150509295509295509295565b805173ffffffffffffffffffffffffffffffffffffffff811681146117a057600080fd5b919050565b6000602082840312156117b757600080fd5b6115798261177c565b6000602082840312156117d257600080fd5b81516117dd816116c4565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561157c5761157c6117e4565b60008060006060848603121561183b57600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561186657600080fd5b5051919050565b64ffffffffff81811683821602808216919082811461188e5761188e6117e4565b505092915050565b64ffffffffff8281168282160390808211156118b4576118b46117e4565b5092915050565b60006101408201905073ffffffffffffffffffffffffffffffffffffffff8084511683528060208501511660208401526fffffffffffffffffffffffffffffffff6040850151166040840152806060850151166060840152506080830151611927608084018215159052565b5060a083015161193b60a084018215159052565b5060c083015161196260c0840182805164ffffffffff908116835260209182015116910152565b5060e0830151805173ffffffffffffffffffffffffffffffffffffffff1661010084015260208101516101208401526118b4565b6000826119cc577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000815180845260005b818110156119f7576020818501810151868301820152016119db565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6000610120808352611a498184018d6119d1565b90508281036020840152611a5d818c6119d1565b604084019a909a52505073ffffffffffffffffffffffffffffffffffffffff9687166060820152948616608086015260a085019390935290841660c0840152831660e08301529091166101009091015292915050565b600067ffffffffffffffff821115611acd57611acd61158f565b5060051b60200190565b600082601f830112611ae857600080fd5b81516020611afd611af883611ab3565b6115e7565b8083825260208201915060208460051b870101935086841115611b1f57600080fd5b602086015b84811015611b4257611b358161177c565b8352918301918301611b24565b509695505050505050565b60006020808385031215611b6057600080fd5b825167ffffffffffffffff80821115611b7857600080fd5b9084019060808287031215611b8c57600080fd5b611b946115be565b825182811115611ba357600080fd5b8301601f81018813611bb457600080fd5b8051611bc2611af882611ab3565b81815260059190911b8201860190868101908a831115611be157600080fd5b928701925b82841015611bff57835182529287019290870190611be6565b84525050508284015182811115611c1557600080fd5b611c2188828601611ad7565b85830152506040830151935081841115611c3a57600080fd5b611c4687858501611ad7565b6040820152606083015160608201528094505050505092915050565b8181038181111561157c5761157c6117e4565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008151808452602080850194506020840160005b83811015611ceb57815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101611cb9565b509495945050505050565b60608152835160608201526020840151608082015260006040850151608060a0840152611d2660e0840182611ca4565b905060608601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08483030160c0850152611d618282611ca4565b73ffffffffffffffffffffffffffffffffffffffff96909616602085015250505060400152919050565b815173ffffffffffffffffffffffffffffffffffffffff16815261016081016020830151611dd1602084018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151611de8604084018262ffffff169052565b506060830151611dfd606084018260020b9052565b506080830151611e12608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611e658285018273ffffffffffffffffffffffffffffffffffffffff169052565b505061014092830151919092015290565b60008060008060808587031215611e8c57600080fd5b8451935060208501516fffffffffffffffffffffffffffffffff81168114611eb357600080fd5b6040860151606090960151949790965092505050565b808202811582820484141761157c5761157c6117e456fe61020060405234801561001157600080fd5b5060405161263438038061263483398101604081905261003091610769565b848980604051806040016040528060018152602001603160f81b8152508c8c816003908161005e91906108bd565b50600461006b82826108bd565b5061007b915083905060056101bd565b6101205261008a8160066101bd565b61014052815160208084019190912060e052815190820120610100524660a05261011760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506001600160a01b03811661015057604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610159816101f0565b506001600160a01b0386166101e0526101723388610242565b61017d87606461027c565b6101a0526101c0939093526001600160a01b0391821661016052811661018052600980546001600160a01b0319169190921617905550610a619350505050565b60006020835110156101d9576101d28361029c565b90506101ea565b816101e484826108bd565b5060ff90505b92915050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03821661026c5760405163ec442f0560e01b815260006004820152602401610147565b610278600083836102da565b5050565b600061271061028b8385610992565b61029591906109a9565b9392505050565b600080829050601f815111156102c7578260405163305a27a960e01b815260040161014791906109cb565b80516102d2826109fe565b179392505050565b6102e583838361042c565b6101c051600a546001600160a01b0316610380576008546001600160a01b038581169116148061032257506008546001600160a01b038481169116145b61037a5760405162461bcd60e51b815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201526265742160e81b6064820152608401610147565b50505050565b804210156103a15760405163063e8a1760e11b815260040160405180910390fd5b60006103ad8242610a22565b9050620151808111156103c1575050505050565b610e10811015610410576103d58484610556565b6103de856105ba565b80156103ee57506103ee846105ba565b61040b576040516324b5c70d60e21b815260040160405180910390fd5b610425565b62015180811015610425576104258484610556565b5050505050565b6001600160a01b03831661045757806002600082825461044c9190610a35565b909155506104c99050565b6001600160a01b038316600090815260208190526040902054818110156104aa5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610147565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166104e557600280548290039055610504565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161054991815260200190565b60405180910390a3505050565b600a546001600160a01b03838116911614610278576001600160a01b03821660009081526020819052604081205461058f908390610a35565b90506101a0518111156105b55760405163065234eb60e31b815260040160405180910390fd5b505050565b6000610160516001600160a01b0316826001600160a01b031614806105f35750610180516001600160a01b0316826001600160a01b0316145b8061066b57506101e051604051631dcf00b560e21b81526001600160a01b0384811660048301529091169063773c02d490602401602060405180830381865afa158015610644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106689190610a48565b15155b806106835750600a546001600160a01b038381169116145b1561068c575060015b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156106c25781810151838201526020016106aa565b50506000910152565b600082601f8301126106dc57600080fd5b81516001600160401b03808211156106f6576106f6610691565b604051601f8301601f19908116603f0116810190828211818310171561071e5761071e610691565b8160405283815286602085880101111561073757600080fd5b6107488460208301602089016106a7565b9695505050505050565b80516001600160a01b038116811461068c57600080fd5b60008060008060008060008060006101208a8c03121561078857600080fd5b89516001600160401b038082111561079f57600080fd5b6107ab8d838e016106cb565b9a5060208c01519150808211156107c157600080fd5b506107ce8c828d016106cb565b98505060408a015196506107e460608b01610752565b95506107f260808b01610752565b945060a08a0151935061080760c08b01610752565b925061081560e08b01610752565b91506108246101008b01610752565b90509295985092959850929598565b600181811c9082168061084757607f821691505b60208210810361086757634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156105b5576000816000526020600020601f850160051c810160208610156108965750805b601f850160051c820191505b818110156108b5578281556001016108a2565b505050505050565b81516001600160401b038111156108d6576108d6610691565b6108ea816108e48454610833565b8461086d565b602080601f83116001811461091f57600084156109075750858301515b600019600386901b1c1916600185901b1785556108b5565b600085815260208120601f198616915b8281101561094e5788860151825594840194600190910190840161092f565b508582101561096c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176101ea576101ea61097c565b6000826109c657634e487b7160e01b600052601260045260246000fd5b500490565b60208152600082518060208401526109ea8160408501602087016106a7565b601f01601f19169190910160400192915050565b805160208083015191908110156108675760001960209190910360031b1b16919050565b818103818111156101ea576101ea61097c565b808201808211156101ea576101ea61097c565b600060208284031215610a5a57600080fd5b5051919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e051611b1f610b1560003960008181610234015261164d0152600081816104460152610e6d015260008181610333015261150301526000818161037801526115b40152600081816102de015261155f01526000610c7901526000610c4c01526000610b7d01526000610b5501526000610ab001526000610ada01526000610b040152611b1f6000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c80637ecebe00116100e3578063a9059cbb1161008c578063dd62ed3e11610066578063dd62ed3e146103e8578063f2fde38b1461042e578063fe4c4af41461044157600080fd5b8063a9059cbb146103a2578063d505accf146103b5578063d5f39488146103c857600080fd5b80638da5cb5b116100bd5780638da5cb5b1461035557806391f03efd1461037357806395d89b411461039a57600080fd5b80637ecebe001461030057806384b0196e1461031357806389f9a1d31461032e57600080fd5b80633644e5151161014557806370a082311161011f57806370a082311461029b578063715018a6146102d15780637c21d5e0146102d957600080fd5b80633644e5151461022757806345d818431461022f578063665a11ca1461027b57600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd14610205578063313ce5671461021857600080fd5b8063018770201461019d57806306fdde03146101b2578063095ea7b3146101d0575b600080fd5b6101b06101ab366004611792565b610468565b005b6101ba610504565b6040516101c79190611818565b60405180910390f35b6101e36101de36600461182b565b610596565b60405190151581526020016101c7565b6002545b6040519081526020016101c7565b6101e3610213366004611855565b6105b0565b604051601281526020016101c7565b6101f76105d4565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101c7565b600a546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76102a9366004611792565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101b06105e3565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101f761030e366004611792565b6105f7565b61031b610622565b6040516101c79796959493929190611891565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b60085473ffffffffffffffffffffffffffffffffffffffff16610256565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101ba610684565b6101e36103b036600461182b565b610693565b6101b06103c3366004611953565b6106a1565b6009546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76103f63660046119c6565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101b061043c366004611792565b610853565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b6104706108b7565b73ffffffffffffffffffffffffffffffffffffffff81166104bd576040517f45ce07b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b606060038054610513906119f9565b80601f016020809104026020016040519081016040528092919081815260200182805461053f906119f9565b801561058c5780601f106105615761010080835404028352916020019161058c565b820191906000526020600020905b81548152906001019060200180831161056f57829003601f168201915b5050505050905090565b6000336105a481858561090a565b60019150505b92915050565b6000336105be85828561091c565b6105c98585856109eb565b506001949350505050565b60006105de610a96565b905090565b6105eb6108b7565b6105f56000610bce565b565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600760205260408120546105aa565b600060608060008060006060610636610c45565b61063e610c72565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b606060048054610513906119f9565b6000336105a48185856109eb565b834211156106e3576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024015b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888861073d8c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060006107a582610c9f565b905060006107b582878787610ce7565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461083c576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106da565b6108478a8a8a61090a565b50505050505050505050565b61085b6108b7565b73ffffffffffffffffffffffffffffffffffffffff81166108ab576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b6108b481610bce565b50565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105f5576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106da565b6109178383836001610d15565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109e557818110156109d6576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106da565b6109e584848484036000610d15565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a3b576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8216610a8b576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b610917838383610e5d565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610afc57507f000000000000000000000000000000000000000000000000000000000000000046145b15610b2657507f000000000000000000000000000000000000000000000000000000000000000090565b6105de604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006005611054565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006006611054565b60006105aa610cac610a96565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b600080600080610cf9888888886110ff565b925092509250610d0982826111f9565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416610d65576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8316610db5576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604080832093871683529290522082905580156109e5578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610e4f91815260200190565b60405180910390a350505050565b610e68838383611301565b600a547f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff16610f765760085473ffffffffffffffffffffffffffffffffffffffff85811691161480610eea575060085473ffffffffffffffffffffffffffffffffffffffff8481169116145b6109e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201527f657421000000000000000000000000000000000000000000000000000000000060648201526084016106da565b80421015610fb0576040517f0c7d142e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610fbc8242611a7b565b905062015180811115610fd0575050505050565b610e1081101561103857610fe484846114ac565b610fed8561155b565b8015610ffd5750610ffd8461155b565b611033576040517f92d71c3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61104d565b6201518081101561104d5761104d84846114ac565b5050505050565b606060ff831461106e57611067836116ee565b90506105aa565b81805461107a906119f9565b80601f01602080910402602001604051908101604052809291908181526020018280546110a6906119f9565b80156110f35780601f106110c8576101008083540402835291602001916110f3565b820191906000526020600020905b8154815290600101906020018083116110d657829003601f168201915b505050505090506105aa565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561113a57506000915060039050826111ef565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561118e573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166111e5575060009250600191508290506111ef565b9250600091508190505b9450945094915050565b600082600381111561120d5761120d611a8e565b03611216575050565b600182600381111561122a5761122a611a8e565b03611261576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561127557611275611a8e565b036112af576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b60038260038111156112c3576112c3611a8e565b036112fd576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b5050565b73ffffffffffffffffffffffffffffffffffffffff831661133957806002600082825461132e9190611abd565b909155506113eb9050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208190526040902054818110156113bf576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106da565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff821661141457600280548290039055611440565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161149f91815260200190565b60405180910390a3505050565b600a5473ffffffffffffffffffffffffffffffffffffffff8381169116146112fd5773ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260408120546114ff908390611abd565b90507f0000000000000000000000000000000000000000000000000000000000000000811115610917576040517f3291a75800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148061160257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b806116bb57506040517f773c02d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063773c02d490602401602060405180830381865afa158015611694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b89190611ad0565b15155b806116e05750600a5473ffffffffffffffffffffffffffffffffffffffff8381169116145b156116e9575060015b919050565b606060006116fb8361172d565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f8111156105aa576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146116e957600080fd5b6000602082840312156117a457600080fd5b6117ad8261176e565b9392505050565b6000815180845260005b818110156117da576020818501810151868301820152016117be565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6020815260006117ad60208301846117b4565b6000806040838503121561183e57600080fd5b6118478361176e565b946020939093013593505050565b60008060006060848603121561186a57600080fd5b6118738461176e565b92506118816020850161176e565b9150604084013590509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e060208401526118ce60e084018a6117b4565b83810360408501526118e0818a6117b4565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b8181101561194157835183529284019291840191600101611925565b50909c9b505050505050505050505050565b600080600080600080600060e0888a03121561196e57600080fd5b6119778861176e565b96506119856020890161176e565b95506040880135945060608801359350608088013560ff811681146119a957600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156119d957600080fd5b6119e28361176e565b91506119f06020840161176e565b90509250929050565b600181811c90821680611a0d57607f821691505b602082108103611a46577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156105aa576105aa611a4c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b808201808211156105aa576105aa611a4c565b600060208284031215611ae257600080fd5b505191905056fea2646970667358221220d1a51e44c0febb110cf683df66e15a81ae5a51f1f72b66266d84022a876cebc064736f6c63430008190033a264697066735822122022e4a9534677a3618bf53d8fab80ffcee6229781237e82b0c3b17f6967058bed64736f6c63430008190033", + "deployedBytecode": "0x60806040526004361061001e5760003560e01c80636c20eebb14610023575b600080fd5b6100366100313660046116d5565b61006d565b6040805173ffffffffffffffffffffffffffffffffffffffff94851681529390921660208401529082015260600160405180910390f35b600080600080600d01543410156100b0576040517f5b35740900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100b933610c40565b6004546005546100ea918b918b918b918b9173ffffffffffffffffffffffffffffffffffffffff9081169116610e11565b6001546008546040517fc9c6539600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808516600483015291821660248201529294508492911690819063c9c65396906044016020604051808303816000875af115801561016d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019191906117a5565b6002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018c905291965083169063095ea7b3906044016020604051808303816000875af115801561020c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023091906117c0565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018b905283169063095ea7b3906044016020604051808303816000875af11580156102a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ca91906117c0565b5060025473ffffffffffffffffffffffffffffffffffffffff168063f305d71934878d8083306102fc42610258611813565b60405160e089901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff9687166004820152602481019590955260448501939093526064840191909152909216608482015260a481019190915260c40160606040518083038185885af115801561038e573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906103b39190611826565b50506008546040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529182166024820152908416915063e6a4390590604401602060405180830381865afa15801561042e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045291906117a5565b955073ffffffffffffffffffffffffffffffffffffffff86166104a1576040517f9272223e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f0187702000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152841690630187702090602401600060405180830381600087803b15801561050a57600080fd5b505af115801561051e573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663715018a66040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b508892505088159050610785576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063a9059cbb9060009083906370a0823190602401602060405180830381865afa158015610600573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106249190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af1158015610694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b891906117c0565b506040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152339073ffffffffffffffffffffffffffffffffffffffff898116917fd289537cc1c5d4ce83b387cec5cdc2658a741cf986d6ad8521af47b377be7ef6918516906370a0823190602401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f9190611854565b60405190815260200160405180910390a3610b84565b60105464ffffffffff908116908a1610156107cc576040517fe47f9cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381169263095ea7b39291169083906370a0823190602401602060405180830381865afa158015610845573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108699190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af11580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd91906117c0565b50610960604080516101008101825260008082526020808301829052828401829052606083018290526080830182905260a083018290528351808501855282815280820183905260c084015283518085019094528184528301529060e082015290565b308082523360208301526040517f70a08231000000000000000000000000000000000000000000000000000000008152600481019190915273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156109d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fa9190611854565b6fffffffffffffffffffffffffffffffff1660408083019190915273ffffffffffffffffffffffffffffffffffffffff8316606083015260006080830152600160a0830181905281518083019092528190610a588d6201518061186d565b610a629190611896565b64ffffffffff168152602001610a7b8c6201518061186d565b64ffffffffff16905260c08201526009546040517fab167ccc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063ab167ccc90610adf9084906004016118bb565b6020604051808303816000875af1158015610afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b229190611854565b33600081815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8d811685529252808320859055519399508b169289917f39679ae33cd13645ec63a701454bd16e6beb24116d89b21c45edb2647cf0bd2e91a4505b600c54610b9c90610b9790600290611996565b610ed6565b610ba4611150565b336000818152601160209081526040808320805460018101825590845291832090910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8b1690811790915590518893927f1a780177e5001bb4f067da390710f31a74a35b48fe52f49d5b60e854744f115491a45050505096509650969350505050565b600654600c546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529092169182906370a0823190602401602060405180830381865afa158015610cb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd99190611854565b1015610d11576040517f09785c3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015230602483015260448201929092526000918316906323b872dd906064016020604051808303816000875af1158015610d93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db791906117c0565b905080610e0c576040517f4611cd5800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240160405180910390fd5b505050565b6000841580610e2b5750610e28426202a300611813565b84105b15610e62576040517f3fbfb3d200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868686600060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163088888833604051610e9c90611582565b610eae99989796959493929190611a35565b604051809103906000f080158015610eca573d6000803e3d6000fd5b50979650505050505050565b600654600480546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821692810192909252602482018490529091169063095ea7b3906044016020604051808303816000875af1158015610f55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7991906117c0565b50600480546006546007546040517f4c09cf4e00000000000000000000000000000000000000000000000000000000815293840185905273ffffffffffffffffffffffffffffffffffffffff91821660248501528116604484015260016064840152600092911690634c09cf4e90608401600060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261104d9190810190611b4d565b905061107a6040518060800160405280600081526020016000815260200160608152602001606081525090565b8281528151805161108d90600190611c62565b8151811061109d5761109d611c75565b60209081029190910181015182820152604080840151818401529083015160608301526004805491517f6bf2df8600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90921691636bf2df8691611119918591309160009101611cf6565b600060405180830381600087803b15801561113357600080fd5b505af1158015611147573d6000803e3d6000fd5b50505050505050565b6006546007546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff928316929091169060009083906370a0823190602401602060405180830381865afa1580156111ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ee9190611854565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa15801561125e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112829190611854565b600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810185905291925085169063095ea7b3906044016020604051808303816000875af11580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132191906117c0565b50600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390529084169063095ea7b3906044016020604051808303816000875af115801561139b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bf91906117c0565b5060006040518061016001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001610bb862ffffff1681526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c60020b8152602001620d89b460020b8152602001838152602001848152602001611463846000600e0154611560565b61146d9085611c62565b8152602001611481856000600e0154611560565b61148b9086611c62565b8152600b5473ffffffffffffffffffffffffffffffffffffffff1660208201526040016114b9426078611813565b9052600a546040517f8831645600000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff1690638831645690611512908490600401611d8b565b6080604051808303816000875af1158015611531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115559190611e76565b505050505050505050565b600061271061156f8385611ec9565b6115799190611996565b90505b92915050565b61263480611ee183390190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516080810167ffffffffffffffff811182821017156115e1576115e161158f565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561162e5761162e61158f565b604052919050565b600082601f83011261164757600080fd5b813567ffffffffffffffff8111156116615761166161158f565b61169260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016115e7565b8181528460208386010111156116a757600080fd5b816020850160208301376000918101602001919091529392505050565b80151581146116d257600080fd5b50565b60008060008060008060c087890312156116ee57600080fd5b863567ffffffffffffffff8082111561170657600080fd5b6117128a838b01611636565b9750602089013591508082111561172857600080fd5b5061173589828a01611636565b9550506040870135935060608701359250608087013564ffffffffff8116811461175e57600080fd5b915060a087013561176e816116c4565b809150509295509295509295565b805173ffffffffffffffffffffffffffffffffffffffff811681146117a057600080fd5b919050565b6000602082840312156117b757600080fd5b6115798261177c565b6000602082840312156117d257600080fd5b81516117dd816116c4565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561157c5761157c6117e4565b60008060006060848603121561183b57600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561186657600080fd5b5051919050565b64ffffffffff81811683821602808216919082811461188e5761188e6117e4565b505092915050565b64ffffffffff8281168282160390808211156118b4576118b46117e4565b5092915050565b60006101408201905073ffffffffffffffffffffffffffffffffffffffff8084511683528060208501511660208401526fffffffffffffffffffffffffffffffff6040850151166040840152806060850151166060840152506080830151611927608084018215159052565b5060a083015161193b60a084018215159052565b5060c083015161196260c0840182805164ffffffffff908116835260209182015116910152565b5060e0830151805173ffffffffffffffffffffffffffffffffffffffff1661010084015260208101516101208401526118b4565b6000826119cc577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000815180845260005b818110156119f7576020818501810151868301820152016119db565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6000610120808352611a498184018d6119d1565b90508281036020840152611a5d818c6119d1565b604084019a909a52505073ffffffffffffffffffffffffffffffffffffffff9687166060820152948616608086015260a085019390935290841660c0840152831660e08301529091166101009091015292915050565b600067ffffffffffffffff821115611acd57611acd61158f565b5060051b60200190565b600082601f830112611ae857600080fd5b81516020611afd611af883611ab3565b6115e7565b8083825260208201915060208460051b870101935086841115611b1f57600080fd5b602086015b84811015611b4257611b358161177c565b8352918301918301611b24565b509695505050505050565b60006020808385031215611b6057600080fd5b825167ffffffffffffffff80821115611b7857600080fd5b9084019060808287031215611b8c57600080fd5b611b946115be565b825182811115611ba357600080fd5b8301601f81018813611bb457600080fd5b8051611bc2611af882611ab3565b81815260059190911b8201860190868101908a831115611be157600080fd5b928701925b82841015611bff57835182529287019290870190611be6565b84525050508284015182811115611c1557600080fd5b611c2188828601611ad7565b85830152506040830151935081841115611c3a57600080fd5b611c4687858501611ad7565b6040820152606083015160608201528094505050505092915050565b8181038181111561157c5761157c6117e4565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008151808452602080850194506020840160005b83811015611ceb57815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101611cb9565b509495945050505050565b60608152835160608201526020840151608082015260006040850151608060a0840152611d2660e0840182611ca4565b905060608601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08483030160c0850152611d618282611ca4565b73ffffffffffffffffffffffffffffffffffffffff96909616602085015250505060400152919050565b815173ffffffffffffffffffffffffffffffffffffffff16815261016081016020830151611dd1602084018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151611de8604084018262ffffff169052565b506060830151611dfd606084018260020b9052565b506080830151611e12608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611e658285018273ffffffffffffffffffffffffffffffffffffffff169052565b505061014092830151919092015290565b60008060008060808587031215611e8c57600080fd5b8451935060208501516fffffffffffffffffffffffffffffffff81168114611eb357600080fd5b6040860151606090960151949790965092505050565b808202811582820484141761157c5761157c6117e456fe61020060405234801561001157600080fd5b5060405161263438038061263483398101604081905261003091610769565b848980604051806040016040528060018152602001603160f81b8152508c8c816003908161005e91906108bd565b50600461006b82826108bd565b5061007b915083905060056101bd565b6101205261008a8160066101bd565b61014052815160208084019190912060e052815190820120610100524660a05261011760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506001600160a01b03811661015057604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610159816101f0565b506001600160a01b0386166101e0526101723388610242565b61017d87606461027c565b6101a0526101c0939093526001600160a01b0391821661016052811661018052600980546001600160a01b0319169190921617905550610a619350505050565b60006020835110156101d9576101d28361029c565b90506101ea565b816101e484826108bd565b5060ff90505b92915050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03821661026c5760405163ec442f0560e01b815260006004820152602401610147565b610278600083836102da565b5050565b600061271061028b8385610992565b61029591906109a9565b9392505050565b600080829050601f815111156102c7578260405163305a27a960e01b815260040161014791906109cb565b80516102d2826109fe565b179392505050565b6102e583838361042c565b6101c051600a546001600160a01b0316610380576008546001600160a01b038581169116148061032257506008546001600160a01b038481169116145b61037a5760405162461bcd60e51b815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201526265742160e81b6064820152608401610147565b50505050565b804210156103a15760405163063e8a1760e11b815260040160405180910390fd5b60006103ad8242610a22565b9050620151808111156103c1575050505050565b610e10811015610410576103d58484610556565b6103de856105ba565b80156103ee57506103ee846105ba565b61040b576040516324b5c70d60e21b815260040160405180910390fd5b610425565b62015180811015610425576104258484610556565b5050505050565b6001600160a01b03831661045757806002600082825461044c9190610a35565b909155506104c99050565b6001600160a01b038316600090815260208190526040902054818110156104aa5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610147565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166104e557600280548290039055610504565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161054991815260200190565b60405180910390a3505050565b600a546001600160a01b03838116911614610278576001600160a01b03821660009081526020819052604081205461058f908390610a35565b90506101a0518111156105b55760405163065234eb60e31b815260040160405180910390fd5b505050565b6000610160516001600160a01b0316826001600160a01b031614806105f35750610180516001600160a01b0316826001600160a01b0316145b8061066b57506101e051604051631dcf00b560e21b81526001600160a01b0384811660048301529091169063773c02d490602401602060405180830381865afa158015610644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106689190610a48565b15155b806106835750600a546001600160a01b038381169116145b1561068c575060015b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156106c25781810151838201526020016106aa565b50506000910152565b600082601f8301126106dc57600080fd5b81516001600160401b03808211156106f6576106f6610691565b604051601f8301601f19908116603f0116810190828211818310171561071e5761071e610691565b8160405283815286602085880101111561073757600080fd5b6107488460208301602089016106a7565b9695505050505050565b80516001600160a01b038116811461068c57600080fd5b60008060008060008060008060006101208a8c03121561078857600080fd5b89516001600160401b038082111561079f57600080fd5b6107ab8d838e016106cb565b9a5060208c01519150808211156107c157600080fd5b506107ce8c828d016106cb565b98505060408a015196506107e460608b01610752565b95506107f260808b01610752565b945060a08a0151935061080760c08b01610752565b925061081560e08b01610752565b91506108246101008b01610752565b90509295985092959850929598565b600181811c9082168061084757607f821691505b60208210810361086757634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156105b5576000816000526020600020601f850160051c810160208610156108965750805b601f850160051c820191505b818110156108b5578281556001016108a2565b505050505050565b81516001600160401b038111156108d6576108d6610691565b6108ea816108e48454610833565b8461086d565b602080601f83116001811461091f57600084156109075750858301515b600019600386901b1c1916600185901b1785556108b5565b600085815260208120601f198616915b8281101561094e5788860151825594840194600190910190840161092f565b508582101561096c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176101ea576101ea61097c565b6000826109c657634e487b7160e01b600052601260045260246000fd5b500490565b60208152600082518060208401526109ea8160408501602087016106a7565b601f01601f19169190910160400192915050565b805160208083015191908110156108675760001960209190910360031b1b16919050565b818103818111156101ea576101ea61097c565b808201808211156101ea576101ea61097c565b600060208284031215610a5a57600080fd5b5051919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e051611b1f610b1560003960008181610234015261164d0152600081816104460152610e6d015260008181610333015261150301526000818161037801526115b40152600081816102de015261155f01526000610c7901526000610c4c01526000610b7d01526000610b5501526000610ab001526000610ada01526000610b040152611b1f6000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c80637ecebe00116100e3578063a9059cbb1161008c578063dd62ed3e11610066578063dd62ed3e146103e8578063f2fde38b1461042e578063fe4c4af41461044157600080fd5b8063a9059cbb146103a2578063d505accf146103b5578063d5f39488146103c857600080fd5b80638da5cb5b116100bd5780638da5cb5b1461035557806391f03efd1461037357806395d89b411461039a57600080fd5b80637ecebe001461030057806384b0196e1461031357806389f9a1d31461032e57600080fd5b80633644e5151161014557806370a082311161011f57806370a082311461029b578063715018a6146102d15780637c21d5e0146102d957600080fd5b80633644e5151461022757806345d818431461022f578063665a11ca1461027b57600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd14610205578063313ce5671461021857600080fd5b8063018770201461019d57806306fdde03146101b2578063095ea7b3146101d0575b600080fd5b6101b06101ab366004611792565b610468565b005b6101ba610504565b6040516101c79190611818565b60405180910390f35b6101e36101de36600461182b565b610596565b60405190151581526020016101c7565b6002545b6040519081526020016101c7565b6101e3610213366004611855565b6105b0565b604051601281526020016101c7565b6101f76105d4565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101c7565b600a546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76102a9366004611792565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101b06105e3565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101f761030e366004611792565b6105f7565b61031b610622565b6040516101c79796959493929190611891565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b60085473ffffffffffffffffffffffffffffffffffffffff16610256565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101ba610684565b6101e36103b036600461182b565b610693565b6101b06103c3366004611953565b6106a1565b6009546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76103f63660046119c6565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101b061043c366004611792565b610853565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b6104706108b7565b73ffffffffffffffffffffffffffffffffffffffff81166104bd576040517f45ce07b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b606060038054610513906119f9565b80601f016020809104026020016040519081016040528092919081815260200182805461053f906119f9565b801561058c5780601f106105615761010080835404028352916020019161058c565b820191906000526020600020905b81548152906001019060200180831161056f57829003601f168201915b5050505050905090565b6000336105a481858561090a565b60019150505b92915050565b6000336105be85828561091c565b6105c98585856109eb565b506001949350505050565b60006105de610a96565b905090565b6105eb6108b7565b6105f56000610bce565b565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600760205260408120546105aa565b600060608060008060006060610636610c45565b61063e610c72565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b606060048054610513906119f9565b6000336105a48185856109eb565b834211156106e3576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024015b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888861073d8c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060006107a582610c9f565b905060006107b582878787610ce7565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461083c576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106da565b6108478a8a8a61090a565b50505050505050505050565b61085b6108b7565b73ffffffffffffffffffffffffffffffffffffffff81166108ab576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b6108b481610bce565b50565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105f5576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106da565b6109178383836001610d15565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109e557818110156109d6576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106da565b6109e584848484036000610d15565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a3b576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8216610a8b576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b610917838383610e5d565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610afc57507f000000000000000000000000000000000000000000000000000000000000000046145b15610b2657507f000000000000000000000000000000000000000000000000000000000000000090565b6105de604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006005611054565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006006611054565b60006105aa610cac610a96565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b600080600080610cf9888888886110ff565b925092509250610d0982826111f9565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416610d65576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8316610db5576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604080832093871683529290522082905580156109e5578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610e4f91815260200190565b60405180910390a350505050565b610e68838383611301565b600a547f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff16610f765760085473ffffffffffffffffffffffffffffffffffffffff85811691161480610eea575060085473ffffffffffffffffffffffffffffffffffffffff8481169116145b6109e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201527f657421000000000000000000000000000000000000000000000000000000000060648201526084016106da565b80421015610fb0576040517f0c7d142e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610fbc8242611a7b565b905062015180811115610fd0575050505050565b610e1081101561103857610fe484846114ac565b610fed8561155b565b8015610ffd5750610ffd8461155b565b611033576040517f92d71c3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61104d565b6201518081101561104d5761104d84846114ac565b5050505050565b606060ff831461106e57611067836116ee565b90506105aa565b81805461107a906119f9565b80601f01602080910402602001604051908101604052809291908181526020018280546110a6906119f9565b80156110f35780601f106110c8576101008083540402835291602001916110f3565b820191906000526020600020905b8154815290600101906020018083116110d657829003601f168201915b505050505090506105aa565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561113a57506000915060039050826111ef565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561118e573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166111e5575060009250600191508290506111ef565b9250600091508190505b9450945094915050565b600082600381111561120d5761120d611a8e565b03611216575050565b600182600381111561122a5761122a611a8e565b03611261576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561127557611275611a8e565b036112af576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b60038260038111156112c3576112c3611a8e565b036112fd576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b5050565b73ffffffffffffffffffffffffffffffffffffffff831661133957806002600082825461132e9190611abd565b909155506113eb9050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208190526040902054818110156113bf576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106da565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff821661141457600280548290039055611440565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161149f91815260200190565b60405180910390a3505050565b600a5473ffffffffffffffffffffffffffffffffffffffff8381169116146112fd5773ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260408120546114ff908390611abd565b90507f0000000000000000000000000000000000000000000000000000000000000000811115610917576040517f3291a75800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148061160257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b806116bb57506040517f773c02d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063773c02d490602401602060405180830381865afa158015611694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b89190611ad0565b15155b806116e05750600a5473ffffffffffffffffffffffffffffffffffffffff8381169116145b156116e9575060015b919050565b606060006116fb8361172d565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f8111156105aa576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146116e957600080fd5b6000602082840312156117a457600080fd5b6117ad8261176e565b9392505050565b6000815180845260005b818110156117da576020818501810151868301820152016117be565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6020815260006117ad60208301846117b4565b6000806040838503121561183e57600080fd5b6118478361176e565b946020939093013593505050565b60008060006060848603121561186a57600080fd5b6118738461176e565b92506118816020850161176e565b9150604084013590509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e060208401526118ce60e084018a6117b4565b83810360408501526118e0818a6117b4565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b8181101561194157835183529284019291840191600101611925565b50909c9b505050505050505050505050565b600080600080600080600060e0888a03121561196e57600080fd5b6119778861176e565b96506119856020890161176e565b95506040880135945060608801359350608088013560ff811681146119a957600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156119d957600080fd5b6119e28361176e565b91506119f06020840161176e565b90509250929050565b600181811c90821680611a0d57607f821691505b602082108103611a46577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156105aa576105aa611a4c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b808201808211156105aa576105aa611a4c565b600060208284031215611ae257600080fd5b505191905056fea2646970667358221220d1a51e44c0febb110cf683df66e15a81ae5a51f1f72b66266d84022a876cebc064736f6c63430008190033a264697066735822122022e4a9534677a3618bf53d8fab80ffcee6229781237e82b0c3b17f6967058bed64736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x90e82cAd005CBf5953fa0F09B69468f0a49340E8" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "LaunchERC20Facet", + "sourceName": "contracts/facets/LaunchERC20Facet.sol", + "abi": [ + { + "inputs": [], + "name": "LaunchERC20Facet__InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__MinimumLockDuration", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__NotEnoughLiquidity", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + } + ], + "name": "LaunchERC20Facet__TranferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__WrongLaunchArguments", + "type": "error" + }, + { + "inputs": [], + "name": "LaunchERC20Facet__ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pair", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_burner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "LiquidityBurned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_pairAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "LiquidityTokensUnlocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_pairAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "LiquidityTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_streamId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_pair", + "type": "address" + } + ], + "name": "StreamCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_creatorAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_streamId", + "type": "uint256" + } + ], + "name": "TokenLaunched", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_tradingStartsAt", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "lockDuration", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "_burnLiquidity", + "type": "bool" + } + ], + "name": "launchERC20", + "outputs": [ + { + "internalType": "address", + "name": "_pair", + "type": "address" + }, + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "streamId", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b5061454a8061001f6000396000f3fe60806040526004361061001e5760003560e01c80636c20eebb14610023575b600080fd5b6100366100313660046116d5565b61006d565b6040805173ffffffffffffffffffffffffffffffffffffffff94851681529390921660208401529082015260600160405180910390f35b600080600080600d01543410156100b0576040517f5b35740900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100b933610c40565b6004546005546100ea918b918b918b918b9173ffffffffffffffffffffffffffffffffffffffff9081169116610e11565b6001546008546040517fc9c6539600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808516600483015291821660248201529294508492911690819063c9c65396906044016020604051808303816000875af115801561016d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019191906117a5565b6002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018c905291965083169063095ea7b3906044016020604051808303816000875af115801561020c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023091906117c0565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018b905283169063095ea7b3906044016020604051808303816000875af11580156102a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ca91906117c0565b5060025473ffffffffffffffffffffffffffffffffffffffff168063f305d71934878d8083306102fc42610258611813565b60405160e089901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff9687166004820152602481019590955260448501939093526064840191909152909216608482015260a481019190915260c40160606040518083038185885af115801561038e573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906103b39190611826565b50506008546040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529182166024820152908416915063e6a4390590604401602060405180830381865afa15801561042e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045291906117a5565b955073ffffffffffffffffffffffffffffffffffffffff86166104a1576040517f9272223e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f0187702000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152841690630187702090602401600060405180830381600087803b15801561050a57600080fd5b505af115801561051e573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663715018a66040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b508892505088159050610785576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063a9059cbb9060009083906370a0823190602401602060405180830381865afa158015610600573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106249190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af1158015610694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b891906117c0565b506040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152339073ffffffffffffffffffffffffffffffffffffffff898116917fd289537cc1c5d4ce83b387cec5cdc2658a741cf986d6ad8521af47b377be7ef6918516906370a0823190602401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f9190611854565b60405190815260200160405180910390a3610b84565b60105464ffffffffff908116908a1610156107cc576040517fe47f9cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381169263095ea7b39291169083906370a0823190602401602060405180830381865afa158015610845573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108699190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af11580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd91906117c0565b50610960604080516101008101825260008082526020808301829052828401829052606083018290526080830182905260a083018290528351808501855282815280820183905260c084015283518085019094528184528301529060e082015290565b308082523360208301526040517f70a08231000000000000000000000000000000000000000000000000000000008152600481019190915273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156109d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fa9190611854565b6fffffffffffffffffffffffffffffffff1660408083019190915273ffffffffffffffffffffffffffffffffffffffff8316606083015260006080830152600160a0830181905281518083019092528190610a588d6201518061186d565b610a629190611896565b64ffffffffff168152602001610a7b8c6201518061186d565b64ffffffffff16905260c08201526009546040517fab167ccc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063ab167ccc90610adf9084906004016118bb565b6020604051808303816000875af1158015610afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b229190611854565b33600081815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8d811685529252808320859055519399508b169289917f39679ae33cd13645ec63a701454bd16e6beb24116d89b21c45edb2647cf0bd2e91a4505b600c54610b9c90610b9790600290611996565b610ed6565b610ba4611150565b336000818152601160209081526040808320805460018101825590845291832090910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8b1690811790915590518893927f1a780177e5001bb4f067da390710f31a74a35b48fe52f49d5b60e854744f115491a45050505096509650969350505050565b600654600c546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529092169182906370a0823190602401602060405180830381865afa158015610cb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd99190611854565b1015610d11576040517f09785c3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015230602483015260448201929092526000918316906323b872dd906064016020604051808303816000875af1158015610d93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db791906117c0565b905080610e0c576040517f4611cd5800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240160405180910390fd5b505050565b6000841580610e2b5750610e28426202a300611813565b84105b15610e62576040517f3fbfb3d200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868686600060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163088888833604051610e9c90611582565b610eae99989796959493929190611a35565b604051809103906000f080158015610eca573d6000803e3d6000fd5b50979650505050505050565b600654600480546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821692810192909252602482018490529091169063095ea7b3906044016020604051808303816000875af1158015610f55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7991906117c0565b50600480546006546007546040517f4c09cf4e00000000000000000000000000000000000000000000000000000000815293840185905273ffffffffffffffffffffffffffffffffffffffff91821660248501528116604484015260016064840152600092911690634c09cf4e90608401600060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261104d9190810190611b4d565b905061107a6040518060800160405280600081526020016000815260200160608152602001606081525090565b8281528151805161108d90600190611c62565b8151811061109d5761109d611c75565b60209081029190910181015182820152604080840151818401529083015160608301526004805491517f6bf2df8600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90921691636bf2df8691611119918591309160009101611cf6565b600060405180830381600087803b15801561113357600080fd5b505af1158015611147573d6000803e3d6000fd5b50505050505050565b6006546007546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff928316929091169060009083906370a0823190602401602060405180830381865afa1580156111ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ee9190611854565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa15801561125e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112829190611854565b600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810185905291925085169063095ea7b3906044016020604051808303816000875af11580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132191906117c0565b50600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390529084169063095ea7b3906044016020604051808303816000875af115801561139b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bf91906117c0565b5060006040518061016001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001610bb862ffffff1681526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c60020b8152602001620d89b460020b8152602001838152602001848152602001611463846000600e0154611560565b61146d9085611c62565b8152602001611481856000600e0154611560565b61148b9086611c62565b8152600b5473ffffffffffffffffffffffffffffffffffffffff1660208201526040016114b9426078611813565b9052600a546040517f8831645600000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff1690638831645690611512908490600401611d8b565b6080604051808303816000875af1158015611531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115559190611e76565b505050505050505050565b600061271061156f8385611ec9565b6115799190611996565b90505b92915050565b61263480611ee183390190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516080810167ffffffffffffffff811182821017156115e1576115e161158f565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561162e5761162e61158f565b604052919050565b600082601f83011261164757600080fd5b813567ffffffffffffffff8111156116615761166161158f565b61169260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016115e7565b8181528460208386010111156116a757600080fd5b816020850160208301376000918101602001919091529392505050565b80151581146116d257600080fd5b50565b60008060008060008060c087890312156116ee57600080fd5b863567ffffffffffffffff8082111561170657600080fd5b6117128a838b01611636565b9750602089013591508082111561172857600080fd5b5061173589828a01611636565b9550506040870135935060608701359250608087013564ffffffffff8116811461175e57600080fd5b915060a087013561176e816116c4565b809150509295509295509295565b805173ffffffffffffffffffffffffffffffffffffffff811681146117a057600080fd5b919050565b6000602082840312156117b757600080fd5b6115798261177c565b6000602082840312156117d257600080fd5b81516117dd816116c4565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561157c5761157c6117e4565b60008060006060848603121561183b57600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561186657600080fd5b5051919050565b64ffffffffff81811683821602808216919082811461188e5761188e6117e4565b505092915050565b64ffffffffff8281168282160390808211156118b4576118b46117e4565b5092915050565b60006101408201905073ffffffffffffffffffffffffffffffffffffffff8084511683528060208501511660208401526fffffffffffffffffffffffffffffffff6040850151166040840152806060850151166060840152506080830151611927608084018215159052565b5060a083015161193b60a084018215159052565b5060c083015161196260c0840182805164ffffffffff908116835260209182015116910152565b5060e0830151805173ffffffffffffffffffffffffffffffffffffffff1661010084015260208101516101208401526118b4565b6000826119cc577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000815180845260005b818110156119f7576020818501810151868301820152016119db565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6000610120808352611a498184018d6119d1565b90508281036020840152611a5d818c6119d1565b604084019a909a52505073ffffffffffffffffffffffffffffffffffffffff9687166060820152948616608086015260a085019390935290841660c0840152831660e08301529091166101009091015292915050565b600067ffffffffffffffff821115611acd57611acd61158f565b5060051b60200190565b600082601f830112611ae857600080fd5b81516020611afd611af883611ab3565b6115e7565b8083825260208201915060208460051b870101935086841115611b1f57600080fd5b602086015b84811015611b4257611b358161177c565b8352918301918301611b24565b509695505050505050565b60006020808385031215611b6057600080fd5b825167ffffffffffffffff80821115611b7857600080fd5b9084019060808287031215611b8c57600080fd5b611b946115be565b825182811115611ba357600080fd5b8301601f81018813611bb457600080fd5b8051611bc2611af882611ab3565b81815260059190911b8201860190868101908a831115611be157600080fd5b928701925b82841015611bff57835182529287019290870190611be6565b84525050508284015182811115611c1557600080fd5b611c2188828601611ad7565b85830152506040830151935081841115611c3a57600080fd5b611c4687858501611ad7565b6040820152606083015160608201528094505050505092915050565b8181038181111561157c5761157c6117e4565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008151808452602080850194506020840160005b83811015611ceb57815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101611cb9565b509495945050505050565b60608152835160608201526020840151608082015260006040850151608060a0840152611d2660e0840182611ca4565b905060608601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08483030160c0850152611d618282611ca4565b73ffffffffffffffffffffffffffffffffffffffff96909616602085015250505060400152919050565b815173ffffffffffffffffffffffffffffffffffffffff16815261016081016020830151611dd1602084018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151611de8604084018262ffffff169052565b506060830151611dfd606084018260020b9052565b506080830151611e12608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611e658285018273ffffffffffffffffffffffffffffffffffffffff169052565b505061014092830151919092015290565b60008060008060808587031215611e8c57600080fd5b8451935060208501516fffffffffffffffffffffffffffffffff81168114611eb357600080fd5b6040860151606090960151949790965092505050565b808202811582820484141761157c5761157c6117e456fe61020060405234801561001157600080fd5b5060405161263438038061263483398101604081905261003091610769565b848980604051806040016040528060018152602001603160f81b8152508c8c816003908161005e91906108bd565b50600461006b82826108bd565b5061007b915083905060056101bd565b6101205261008a8160066101bd565b61014052815160208084019190912060e052815190820120610100524660a05261011760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506001600160a01b03811661015057604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610159816101f0565b506001600160a01b0386166101e0526101723388610242565b61017d87606461027c565b6101a0526101c0939093526001600160a01b0391821661016052811661018052600980546001600160a01b0319169190921617905550610a619350505050565b60006020835110156101d9576101d28361029c565b90506101ea565b816101e484826108bd565b5060ff90505b92915050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03821661026c5760405163ec442f0560e01b815260006004820152602401610147565b610278600083836102da565b5050565b600061271061028b8385610992565b61029591906109a9565b9392505050565b600080829050601f815111156102c7578260405163305a27a960e01b815260040161014791906109cb565b80516102d2826109fe565b179392505050565b6102e583838361042c565b6101c051600a546001600160a01b0316610380576008546001600160a01b038581169116148061032257506008546001600160a01b038481169116145b61037a5760405162461bcd60e51b815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201526265742160e81b6064820152608401610147565b50505050565b804210156103a15760405163063e8a1760e11b815260040160405180910390fd5b60006103ad8242610a22565b9050620151808111156103c1575050505050565b610e10811015610410576103d58484610556565b6103de856105ba565b80156103ee57506103ee846105ba565b61040b576040516324b5c70d60e21b815260040160405180910390fd5b610425565b62015180811015610425576104258484610556565b5050505050565b6001600160a01b03831661045757806002600082825461044c9190610a35565b909155506104c99050565b6001600160a01b038316600090815260208190526040902054818110156104aa5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610147565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166104e557600280548290039055610504565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161054991815260200190565b60405180910390a3505050565b600a546001600160a01b03838116911614610278576001600160a01b03821660009081526020819052604081205461058f908390610a35565b90506101a0518111156105b55760405163065234eb60e31b815260040160405180910390fd5b505050565b6000610160516001600160a01b0316826001600160a01b031614806105f35750610180516001600160a01b0316826001600160a01b0316145b8061066b57506101e051604051631dcf00b560e21b81526001600160a01b0384811660048301529091169063773c02d490602401602060405180830381865afa158015610644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106689190610a48565b15155b806106835750600a546001600160a01b038381169116145b1561068c575060015b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156106c25781810151838201526020016106aa565b50506000910152565b600082601f8301126106dc57600080fd5b81516001600160401b03808211156106f6576106f6610691565b604051601f8301601f19908116603f0116810190828211818310171561071e5761071e610691565b8160405283815286602085880101111561073757600080fd5b6107488460208301602089016106a7565b9695505050505050565b80516001600160a01b038116811461068c57600080fd5b60008060008060008060008060006101208a8c03121561078857600080fd5b89516001600160401b038082111561079f57600080fd5b6107ab8d838e016106cb565b9a5060208c01519150808211156107c157600080fd5b506107ce8c828d016106cb565b98505060408a015196506107e460608b01610752565b95506107f260808b01610752565b945060a08a0151935061080760c08b01610752565b925061081560e08b01610752565b91506108246101008b01610752565b90509295985092959850929598565b600181811c9082168061084757607f821691505b60208210810361086757634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156105b5576000816000526020600020601f850160051c810160208610156108965750805b601f850160051c820191505b818110156108b5578281556001016108a2565b505050505050565b81516001600160401b038111156108d6576108d6610691565b6108ea816108e48454610833565b8461086d565b602080601f83116001811461091f57600084156109075750858301515b600019600386901b1c1916600185901b1785556108b5565b600085815260208120601f198616915b8281101561094e5788860151825594840194600190910190840161092f565b508582101561096c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176101ea576101ea61097c565b6000826109c657634e487b7160e01b600052601260045260246000fd5b500490565b60208152600082518060208401526109ea8160408501602087016106a7565b601f01601f19169190910160400192915050565b805160208083015191908110156108675760001960209190910360031b1b16919050565b818103818111156101ea576101ea61097c565b808201808211156101ea576101ea61097c565b600060208284031215610a5a57600080fd5b5051919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e051611b1f610b1560003960008181610234015261164d0152600081816104460152610e6d015260008181610333015261150301526000818161037801526115b40152600081816102de015261155f01526000610c7901526000610c4c01526000610b7d01526000610b5501526000610ab001526000610ada01526000610b040152611b1f6000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c80637ecebe00116100e3578063a9059cbb1161008c578063dd62ed3e11610066578063dd62ed3e146103e8578063f2fde38b1461042e578063fe4c4af41461044157600080fd5b8063a9059cbb146103a2578063d505accf146103b5578063d5f39488146103c857600080fd5b80638da5cb5b116100bd5780638da5cb5b1461035557806391f03efd1461037357806395d89b411461039a57600080fd5b80637ecebe001461030057806384b0196e1461031357806389f9a1d31461032e57600080fd5b80633644e5151161014557806370a082311161011f57806370a082311461029b578063715018a6146102d15780637c21d5e0146102d957600080fd5b80633644e5151461022757806345d818431461022f578063665a11ca1461027b57600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd14610205578063313ce5671461021857600080fd5b8063018770201461019d57806306fdde03146101b2578063095ea7b3146101d0575b600080fd5b6101b06101ab366004611792565b610468565b005b6101ba610504565b6040516101c79190611818565b60405180910390f35b6101e36101de36600461182b565b610596565b60405190151581526020016101c7565b6002545b6040519081526020016101c7565b6101e3610213366004611855565b6105b0565b604051601281526020016101c7565b6101f76105d4565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101c7565b600a546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76102a9366004611792565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101b06105e3565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101f761030e366004611792565b6105f7565b61031b610622565b6040516101c79796959493929190611891565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b60085473ffffffffffffffffffffffffffffffffffffffff16610256565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101ba610684565b6101e36103b036600461182b565b610693565b6101b06103c3366004611953565b6106a1565b6009546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76103f63660046119c6565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101b061043c366004611792565b610853565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b6104706108b7565b73ffffffffffffffffffffffffffffffffffffffff81166104bd576040517f45ce07b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b606060038054610513906119f9565b80601f016020809104026020016040519081016040528092919081815260200182805461053f906119f9565b801561058c5780601f106105615761010080835404028352916020019161058c565b820191906000526020600020905b81548152906001019060200180831161056f57829003601f168201915b5050505050905090565b6000336105a481858561090a565b60019150505b92915050565b6000336105be85828561091c565b6105c98585856109eb565b506001949350505050565b60006105de610a96565b905090565b6105eb6108b7565b6105f56000610bce565b565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600760205260408120546105aa565b600060608060008060006060610636610c45565b61063e610c72565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b606060048054610513906119f9565b6000336105a48185856109eb565b834211156106e3576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024015b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888861073d8c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060006107a582610c9f565b905060006107b582878787610ce7565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461083c576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106da565b6108478a8a8a61090a565b50505050505050505050565b61085b6108b7565b73ffffffffffffffffffffffffffffffffffffffff81166108ab576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b6108b481610bce565b50565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105f5576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106da565b6109178383836001610d15565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109e557818110156109d6576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106da565b6109e584848484036000610d15565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a3b576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8216610a8b576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b610917838383610e5d565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610afc57507f000000000000000000000000000000000000000000000000000000000000000046145b15610b2657507f000000000000000000000000000000000000000000000000000000000000000090565b6105de604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006005611054565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006006611054565b60006105aa610cac610a96565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b600080600080610cf9888888886110ff565b925092509250610d0982826111f9565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416610d65576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8316610db5576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604080832093871683529290522082905580156109e5578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610e4f91815260200190565b60405180910390a350505050565b610e68838383611301565b600a547f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff16610f765760085473ffffffffffffffffffffffffffffffffffffffff85811691161480610eea575060085473ffffffffffffffffffffffffffffffffffffffff8481169116145b6109e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201527f657421000000000000000000000000000000000000000000000000000000000060648201526084016106da565b80421015610fb0576040517f0c7d142e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610fbc8242611a7b565b905062015180811115610fd0575050505050565b610e1081101561103857610fe484846114ac565b610fed8561155b565b8015610ffd5750610ffd8461155b565b611033576040517f92d71c3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61104d565b6201518081101561104d5761104d84846114ac565b5050505050565b606060ff831461106e57611067836116ee565b90506105aa565b81805461107a906119f9565b80601f01602080910402602001604051908101604052809291908181526020018280546110a6906119f9565b80156110f35780601f106110c8576101008083540402835291602001916110f3565b820191906000526020600020905b8154815290600101906020018083116110d657829003601f168201915b505050505090506105aa565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561113a57506000915060039050826111ef565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561118e573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166111e5575060009250600191508290506111ef565b9250600091508190505b9450945094915050565b600082600381111561120d5761120d611a8e565b03611216575050565b600182600381111561122a5761122a611a8e565b03611261576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561127557611275611a8e565b036112af576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b60038260038111156112c3576112c3611a8e565b036112fd576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b5050565b73ffffffffffffffffffffffffffffffffffffffff831661133957806002600082825461132e9190611abd565b909155506113eb9050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208190526040902054818110156113bf576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106da565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff821661141457600280548290039055611440565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161149f91815260200190565b60405180910390a3505050565b600a5473ffffffffffffffffffffffffffffffffffffffff8381169116146112fd5773ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260408120546114ff908390611abd565b90507f0000000000000000000000000000000000000000000000000000000000000000811115610917576040517f3291a75800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148061160257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b806116bb57506040517f773c02d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063773c02d490602401602060405180830381865afa158015611694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b89190611ad0565b15155b806116e05750600a5473ffffffffffffffffffffffffffffffffffffffff8381169116145b156116e9575060015b919050565b606060006116fb8361172d565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f8111156105aa576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146116e957600080fd5b6000602082840312156117a457600080fd5b6117ad8261176e565b9392505050565b6000815180845260005b818110156117da576020818501810151868301820152016117be565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6020815260006117ad60208301846117b4565b6000806040838503121561183e57600080fd5b6118478361176e565b946020939093013593505050565b60008060006060848603121561186a57600080fd5b6118738461176e565b92506118816020850161176e565b9150604084013590509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e060208401526118ce60e084018a6117b4565b83810360408501526118e0818a6117b4565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b8181101561194157835183529284019291840191600101611925565b50909c9b505050505050505050505050565b600080600080600080600060e0888a03121561196e57600080fd5b6119778861176e565b96506119856020890161176e565b95506040880135945060608801359350608088013560ff811681146119a957600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156119d957600080fd5b6119e28361176e565b91506119f06020840161176e565b90509250929050565b600181811c90821680611a0d57607f821691505b602082108103611a46577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156105aa576105aa611a4c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b808201808211156105aa576105aa611a4c565b600060208284031215611ae257600080fd5b505191905056fea2646970667358221220d1a51e44c0febb110cf683df66e15a81ae5a51f1f72b66266d84022a876cebc064736f6c63430008190033a264697066735822122022e4a9534677a3618bf53d8fab80ffcee6229781237e82b0c3b17f6967058bed64736f6c63430008190033", + "deployedBytecode": "0x60806040526004361061001e5760003560e01c80636c20eebb14610023575b600080fd5b6100366100313660046116d5565b61006d565b6040805173ffffffffffffffffffffffffffffffffffffffff94851681529390921660208401529082015260600160405180910390f35b600080600080600d01543410156100b0576040517f5b35740900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100b933610c40565b6004546005546100ea918b918b918b918b9173ffffffffffffffffffffffffffffffffffffffff9081169116610e11565b6001546008546040517fc9c6539600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808516600483015291821660248201529294508492911690819063c9c65396906044016020604051808303816000875af115801561016d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019191906117a5565b6002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018c905291965083169063095ea7b3906044016020604051808303816000875af115801561020c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023091906117c0565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018b905283169063095ea7b3906044016020604051808303816000875af11580156102a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ca91906117c0565b5060025473ffffffffffffffffffffffffffffffffffffffff168063f305d71934878d8083306102fc42610258611813565b60405160e089901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff9687166004820152602481019590955260448501939093526064840191909152909216608482015260a481019190915260c40160606040518083038185885af115801561038e573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906103b39190611826565b50506008546040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529182166024820152908416915063e6a4390590604401602060405180830381865afa15801561042e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045291906117a5565b955073ffffffffffffffffffffffffffffffffffffffff86166104a1576040517f9272223e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f0187702000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152841690630187702090602401600060405180830381600087803b15801561050a57600080fd5b505af115801561051e573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663715018a66040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b508892505088159050610785576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063a9059cbb9060009083906370a0823190602401602060405180830381865afa158015610600573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106249190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af1158015610694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b891906117c0565b506040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152339073ffffffffffffffffffffffffffffffffffffffff898116917fd289537cc1c5d4ce83b387cec5cdc2658a741cf986d6ad8521af47b377be7ef6918516906370a0823190602401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f9190611854565b60405190815260200160405180910390a3610b84565b60105464ffffffffff908116908a1610156107cc576040517fe47f9cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381169263095ea7b39291169083906370a0823190602401602060405180830381865afa158015610845573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108699190611854565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af11580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd91906117c0565b50610960604080516101008101825260008082526020808301829052828401829052606083018290526080830182905260a083018290528351808501855282815280820183905260c084015283518085019094528184528301529060e082015290565b308082523360208301526040517f70a08231000000000000000000000000000000000000000000000000000000008152600481019190915273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156109d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fa9190611854565b6fffffffffffffffffffffffffffffffff1660408083019190915273ffffffffffffffffffffffffffffffffffffffff8316606083015260006080830152600160a0830181905281518083019092528190610a588d6201518061186d565b610a629190611896565b64ffffffffff168152602001610a7b8c6201518061186d565b64ffffffffff16905260c08201526009546040517fab167ccc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063ab167ccc90610adf9084906004016118bb565b6020604051808303816000875af1158015610afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b229190611854565b33600081815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8d811685529252808320859055519399508b169289917f39679ae33cd13645ec63a701454bd16e6beb24116d89b21c45edb2647cf0bd2e91a4505b600c54610b9c90610b9790600290611996565b610ed6565b610ba4611150565b336000818152601160209081526040808320805460018101825590845291832090910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8b1690811790915590518893927f1a780177e5001bb4f067da390710f31a74a35b48fe52f49d5b60e854744f115491a45050505096509650969350505050565b600654600c546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529092169182906370a0823190602401602060405180830381865afa158015610cb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd99190611854565b1015610d11576040517f09785c3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015230602483015260448201929092526000918316906323b872dd906064016020604051808303816000875af1158015610d93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db791906117c0565b905080610e0c576040517f4611cd5800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260240160405180910390fd5b505050565b6000841580610e2b5750610e28426202a300611813565b84105b15610e62576040517f3fbfb3d200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868686600060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163088888833604051610e9c90611582565b610eae99989796959493929190611a35565b604051809103906000f080158015610eca573d6000803e3d6000fd5b50979650505050505050565b600654600480546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821692810192909252602482018490529091169063095ea7b3906044016020604051808303816000875af1158015610f55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7991906117c0565b50600480546006546007546040517f4c09cf4e00000000000000000000000000000000000000000000000000000000815293840185905273ffffffffffffffffffffffffffffffffffffffff91821660248501528116604484015260016064840152600092911690634c09cf4e90608401600060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261104d9190810190611b4d565b905061107a6040518060800160405280600081526020016000815260200160608152602001606081525090565b8281528151805161108d90600190611c62565b8151811061109d5761109d611c75565b60209081029190910181015182820152604080840151818401529083015160608301526004805491517f6bf2df8600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90921691636bf2df8691611119918591309160009101611cf6565b600060405180830381600087803b15801561113357600080fd5b505af1158015611147573d6000803e3d6000fd5b50505050505050565b6006546007546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff928316929091169060009083906370a0823190602401602060405180830381865afa1580156111ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ee9190611854565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa15801561125e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112829190611854565b600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810185905291925085169063095ea7b3906044016020604051808303816000875af11580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132191906117c0565b50600a546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390529084169063095ea7b3906044016020604051808303816000875af115801561139b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bf91906117c0565b5060006040518061016001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001610bb862ffffff1681526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c60020b8152602001620d89b460020b8152602001838152602001848152602001611463846000600e0154611560565b61146d9085611c62565b8152602001611481856000600e0154611560565b61148b9086611c62565b8152600b5473ffffffffffffffffffffffffffffffffffffffff1660208201526040016114b9426078611813565b9052600a546040517f8831645600000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff1690638831645690611512908490600401611d8b565b6080604051808303816000875af1158015611531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115559190611e76565b505050505050505050565b600061271061156f8385611ec9565b6115799190611996565b90505b92915050565b61263480611ee183390190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516080810167ffffffffffffffff811182821017156115e1576115e161158f565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561162e5761162e61158f565b604052919050565b600082601f83011261164757600080fd5b813567ffffffffffffffff8111156116615761166161158f565b61169260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016115e7565b8181528460208386010111156116a757600080fd5b816020850160208301376000918101602001919091529392505050565b80151581146116d257600080fd5b50565b60008060008060008060c087890312156116ee57600080fd5b863567ffffffffffffffff8082111561170657600080fd5b6117128a838b01611636565b9750602089013591508082111561172857600080fd5b5061173589828a01611636565b9550506040870135935060608701359250608087013564ffffffffff8116811461175e57600080fd5b915060a087013561176e816116c4565b809150509295509295509295565b805173ffffffffffffffffffffffffffffffffffffffff811681146117a057600080fd5b919050565b6000602082840312156117b757600080fd5b6115798261177c565b6000602082840312156117d257600080fd5b81516117dd816116c4565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561157c5761157c6117e4565b60008060006060848603121561183b57600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561186657600080fd5b5051919050565b64ffffffffff81811683821602808216919082811461188e5761188e6117e4565b505092915050565b64ffffffffff8281168282160390808211156118b4576118b46117e4565b5092915050565b60006101408201905073ffffffffffffffffffffffffffffffffffffffff8084511683528060208501511660208401526fffffffffffffffffffffffffffffffff6040850151166040840152806060850151166060840152506080830151611927608084018215159052565b5060a083015161193b60a084018215159052565b5060c083015161196260c0840182805164ffffffffff908116835260209182015116910152565b5060e0830151805173ffffffffffffffffffffffffffffffffffffffff1661010084015260208101516101208401526118b4565b6000826119cc577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000815180845260005b818110156119f7576020818501810151868301820152016119db565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6000610120808352611a498184018d6119d1565b90508281036020840152611a5d818c6119d1565b604084019a909a52505073ffffffffffffffffffffffffffffffffffffffff9687166060820152948616608086015260a085019390935290841660c0840152831660e08301529091166101009091015292915050565b600067ffffffffffffffff821115611acd57611acd61158f565b5060051b60200190565b600082601f830112611ae857600080fd5b81516020611afd611af883611ab3565b6115e7565b8083825260208201915060208460051b870101935086841115611b1f57600080fd5b602086015b84811015611b4257611b358161177c565b8352918301918301611b24565b509695505050505050565b60006020808385031215611b6057600080fd5b825167ffffffffffffffff80821115611b7857600080fd5b9084019060808287031215611b8c57600080fd5b611b946115be565b825182811115611ba357600080fd5b8301601f81018813611bb457600080fd5b8051611bc2611af882611ab3565b81815260059190911b8201860190868101908a831115611be157600080fd5b928701925b82841015611bff57835182529287019290870190611be6565b84525050508284015182811115611c1557600080fd5b611c2188828601611ad7565b85830152506040830151935081841115611c3a57600080fd5b611c4687858501611ad7565b6040820152606083015160608201528094505050505092915050565b8181038181111561157c5761157c6117e4565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008151808452602080850194506020840160005b83811015611ceb57815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101611cb9565b509495945050505050565b60608152835160608201526020840151608082015260006040850151608060a0840152611d2660e0840182611ca4565b905060608601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08483030160c0850152611d618282611ca4565b73ffffffffffffffffffffffffffffffffffffffff96909616602085015250505060400152919050565b815173ffffffffffffffffffffffffffffffffffffffff16815261016081016020830151611dd1602084018273ffffffffffffffffffffffffffffffffffffffff169052565b506040830151611de8604084018262ffffff169052565b506060830151611dfd606084018260020b9052565b506080830151611e12608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611e658285018273ffffffffffffffffffffffffffffffffffffffff169052565b505061014092830151919092015290565b60008060008060808587031215611e8c57600080fd5b8451935060208501516fffffffffffffffffffffffffffffffff81168114611eb357600080fd5b6040860151606090960151949790965092505050565b808202811582820484141761157c5761157c6117e456fe61020060405234801561001157600080fd5b5060405161263438038061263483398101604081905261003091610769565b848980604051806040016040528060018152602001603160f81b8152508c8c816003908161005e91906108bd565b50600461006b82826108bd565b5061007b915083905060056101bd565b6101205261008a8160066101bd565b61014052815160208084019190912060e052815190820120610100524660a05261011760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506001600160a01b03811661015057604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610159816101f0565b506001600160a01b0386166101e0526101723388610242565b61017d87606461027c565b6101a0526101c0939093526001600160a01b0391821661016052811661018052600980546001600160a01b0319169190921617905550610a619350505050565b60006020835110156101d9576101d28361029c565b90506101ea565b816101e484826108bd565b5060ff90505b92915050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03821661026c5760405163ec442f0560e01b815260006004820152602401610147565b610278600083836102da565b5050565b600061271061028b8385610992565b61029591906109a9565b9392505050565b600080829050601f815111156102c7578260405163305a27a960e01b815260040161014791906109cb565b80516102d2826109fe565b179392505050565b6102e583838361042c565b6101c051600a546001600160a01b0316610380576008546001600160a01b038581169116148061032257506008546001600160a01b038481169116145b61037a5760405162461bcd60e51b815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201526265742160e81b6064820152608401610147565b50505050565b804210156103a15760405163063e8a1760e11b815260040160405180910390fd5b60006103ad8242610a22565b9050620151808111156103c1575050505050565b610e10811015610410576103d58484610556565b6103de856105ba565b80156103ee57506103ee846105ba565b61040b576040516324b5c70d60e21b815260040160405180910390fd5b610425565b62015180811015610425576104258484610556565b5050505050565b6001600160a01b03831661045757806002600082825461044c9190610a35565b909155506104c99050565b6001600160a01b038316600090815260208190526040902054818110156104aa5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610147565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166104e557600280548290039055610504565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161054991815260200190565b60405180910390a3505050565b600a546001600160a01b03838116911614610278576001600160a01b03821660009081526020819052604081205461058f908390610a35565b90506101a0518111156105b55760405163065234eb60e31b815260040160405180910390fd5b505050565b6000610160516001600160a01b0316826001600160a01b031614806105f35750610180516001600160a01b0316826001600160a01b0316145b8061066b57506101e051604051631dcf00b560e21b81526001600160a01b0384811660048301529091169063773c02d490602401602060405180830381865afa158015610644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106689190610a48565b15155b806106835750600a546001600160a01b038381169116145b1561068c575060015b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156106c25781810151838201526020016106aa565b50506000910152565b600082601f8301126106dc57600080fd5b81516001600160401b03808211156106f6576106f6610691565b604051601f8301601f19908116603f0116810190828211818310171561071e5761071e610691565b8160405283815286602085880101111561073757600080fd5b6107488460208301602089016106a7565b9695505050505050565b80516001600160a01b038116811461068c57600080fd5b60008060008060008060008060006101208a8c03121561078857600080fd5b89516001600160401b038082111561079f57600080fd5b6107ab8d838e016106cb565b9a5060208c01519150808211156107c157600080fd5b506107ce8c828d016106cb565b98505060408a015196506107e460608b01610752565b95506107f260808b01610752565b945060a08a0151935061080760c08b01610752565b925061081560e08b01610752565b91506108246101008b01610752565b90509295985092959850929598565b600181811c9082168061084757607f821691505b60208210810361086757634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156105b5576000816000526020600020601f850160051c810160208610156108965750805b601f850160051c820191505b818110156108b5578281556001016108a2565b505050505050565b81516001600160401b038111156108d6576108d6610691565b6108ea816108e48454610833565b8461086d565b602080601f83116001811461091f57600084156109075750858301515b600019600386901b1c1916600185901b1785556108b5565b600085815260208120601f198616915b8281101561094e5788860151825594840194600190910190840161092f565b508582101561096c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176101ea576101ea61097c565b6000826109c657634e487b7160e01b600052601260045260246000fd5b500490565b60208152600082518060208401526109ea8160408501602087016106a7565b601f01601f19169190910160400192915050565b805160208083015191908110156108675760001960209190910360031b1b16919050565b818103818111156101ea576101ea61097c565b808201808211156101ea576101ea61097c565b600060208284031215610a5a57600080fd5b5051919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e051611b1f610b1560003960008181610234015261164d0152600081816104460152610e6d015260008181610333015261150301526000818161037801526115b40152600081816102de015261155f01526000610c7901526000610c4c01526000610b7d01526000610b5501526000610ab001526000610ada01526000610b040152611b1f6000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c80637ecebe00116100e3578063a9059cbb1161008c578063dd62ed3e11610066578063dd62ed3e146103e8578063f2fde38b1461042e578063fe4c4af41461044157600080fd5b8063a9059cbb146103a2578063d505accf146103b5578063d5f39488146103c857600080fd5b80638da5cb5b116100bd5780638da5cb5b1461035557806391f03efd1461037357806395d89b411461039a57600080fd5b80637ecebe001461030057806384b0196e1461031357806389f9a1d31461032e57600080fd5b80633644e5151161014557806370a082311161011f57806370a082311461029b578063715018a6146102d15780637c21d5e0146102d957600080fd5b80633644e5151461022757806345d818431461022f578063665a11ca1461027b57600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd14610205578063313ce5671461021857600080fd5b8063018770201461019d57806306fdde03146101b2578063095ea7b3146101d0575b600080fd5b6101b06101ab366004611792565b610468565b005b6101ba610504565b6040516101c79190611818565b60405180910390f35b6101e36101de36600461182b565b610596565b60405190151581526020016101c7565b6002545b6040519081526020016101c7565b6101e3610213366004611855565b6105b0565b604051601281526020016101c7565b6101f76105d4565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101c7565b600a546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76102a9366004611792565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101b06105e3565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101f761030e366004611792565b6105f7565b61031b610622565b6040516101c79796959493929190611891565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b60085473ffffffffffffffffffffffffffffffffffffffff16610256565b6102567f000000000000000000000000000000000000000000000000000000000000000081565b6101ba610684565b6101e36103b036600461182b565b610693565b6101b06103c3366004611953565b6106a1565b6009546102569073ffffffffffffffffffffffffffffffffffffffff1681565b6101f76103f63660046119c6565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101b061043c366004611792565b610853565b6101f77f000000000000000000000000000000000000000000000000000000000000000081565b6104706108b7565b73ffffffffffffffffffffffffffffffffffffffff81166104bd576040517f45ce07b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b606060038054610513906119f9565b80601f016020809104026020016040519081016040528092919081815260200182805461053f906119f9565b801561058c5780601f106105615761010080835404028352916020019161058c565b820191906000526020600020905b81548152906001019060200180831161056f57829003601f168201915b5050505050905090565b6000336105a481858561090a565b60019150505b92915050565b6000336105be85828561091c565b6105c98585856109eb565b506001949350505050565b60006105de610a96565b905090565b6105eb6108b7565b6105f56000610bce565b565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600760205260408120546105aa565b600060608060008060006060610636610c45565b61063e610c72565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b606060048054610513906119f9565b6000336105a48185856109eb565b834211156106e3576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024015b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888861073d8c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060006107a582610c9f565b905060006107b582878787610ce7565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461083c576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106da565b6108478a8a8a61090a565b50505050505050505050565b61085b6108b7565b73ffffffffffffffffffffffffffffffffffffffff81166108ab576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b6108b481610bce565b50565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105f5576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106da565b6109178383836001610d15565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109e557818110156109d6576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106da565b6109e584848484036000610d15565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a3b576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8216610a8b576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b610917838383610e5d565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610afc57507f000000000000000000000000000000000000000000000000000000000000000046145b15610b2657507f000000000000000000000000000000000000000000000000000000000000000090565b6105de604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006005611054565b60606105de7f00000000000000000000000000000000000000000000000000000000000000006006611054565b60006105aa610cac610a96565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b600080600080610cf9888888886110ff565b925092509250610d0982826111f9565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416610d65576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff8316610db5576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106da565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604080832093871683529290522082905580156109e5578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610e4f91815260200190565b60405180910390a350505050565b610e68838383611301565b600a547f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff16610f765760085473ffffffffffffffffffffffffffffffffffffffff85811691161480610eea575060085473ffffffffffffffffffffffffffffffffffffffff8481169116145b6109e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201527f657421000000000000000000000000000000000000000000000000000000000060648201526084016106da565b80421015610fb0576040517f0c7d142e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610fbc8242611a7b565b905062015180811115610fd0575050505050565b610e1081101561103857610fe484846114ac565b610fed8561155b565b8015610ffd5750610ffd8461155b565b611033576040517f92d71c3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61104d565b6201518081101561104d5761104d84846114ac565b5050505050565b606060ff831461106e57611067836116ee565b90506105aa565b81805461107a906119f9565b80601f01602080910402602001604051908101604052809291908181526020018280546110a6906119f9565b80156110f35780601f106110c8576101008083540402835291602001916110f3565b820191906000526020600020905b8154815290600101906020018083116110d657829003601f168201915b505050505090506105aa565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561113a57506000915060039050826111ef565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561118e573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166111e5575060009250600191508290506111ef565b9250600091508190505b9450945094915050565b600082600381111561120d5761120d611a8e565b03611216575050565b600182600381111561122a5761122a611a8e565b03611261576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561127557611275611a8e565b036112af576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b60038260038111156112c3576112c3611a8e565b036112fd576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106da565b5050565b73ffffffffffffffffffffffffffffffffffffffff831661133957806002600082825461132e9190611abd565b909155506113eb9050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208190526040902054818110156113bf576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106da565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff821661141457600280548290039055611440565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161149f91815260200190565b60405180910390a3505050565b600a5473ffffffffffffffffffffffffffffffffffffffff8381169116146112fd5773ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260408120546114ff908390611abd565b90507f0000000000000000000000000000000000000000000000000000000000000000811115610917576040517f3291a75800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148061160257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b806116bb57506040517f773c02d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063773c02d490602401602060405180830381865afa158015611694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b89190611ad0565b15155b806116e05750600a5473ffffffffffffffffffffffffffffffffffffffff8381169116145b156116e9575060015b919050565b606060006116fb8361172d565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f8111156105aa576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146116e957600080fd5b6000602082840312156117a457600080fd5b6117ad8261176e565b9392505050565b6000815180845260005b818110156117da576020818501810151868301820152016117be565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6020815260006117ad60208301846117b4565b6000806040838503121561183e57600080fd5b6118478361176e565b946020939093013593505050565b60008060006060848603121561186a57600080fd5b6118738461176e565b92506118816020850161176e565b9150604084013590509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e060208401526118ce60e084018a6117b4565b83810360408501526118e0818a6117b4565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b8181101561194157835183529284019291840191600101611925565b50909c9b505050505050505050505050565b600080600080600080600060e0888a03121561196e57600080fd5b6119778861176e565b96506119856020890161176e565b95506040880135945060608801359350608088013560ff811681146119a957600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156119d957600080fd5b6119e28361176e565b91506119f06020840161176e565b90509250929050565b600181811c90821680611a0d57607f821691505b602082108103611a46577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156105aa576105aa611a4c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b808201808211156105aa576105aa611a4c565b600060208284031215611ae257600080fd5b505191905056fea2646970667358221220d1a51e44c0febb110cf683df66e15a81ae5a51f1f72b66266d84022a876cebc064736f6c63430008190033a264697066735822122022e4a9534677a3618bf53d8fab80ffcee6229781237e82b0c3b17f6967058bed64736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0xC7FeC3940a6aB2b584EeE84f619976DDd5765E8B" + } +} \ No newline at end of file diff --git a/deployments/LiquidityLockFacet.json b/deployments/LiquidityLockFacet.json new file mode 100644 index 0000000..2d063e8 --- /dev/null +++ b/deployments/LiquidityLockFacet.json @@ -0,0 +1,222 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "LiquidityLockFacet", + "sourceName": "contracts/facets/LiquidityLockFacet.sol", + "abi": [ + { + "inputs": [], + "name": "LiquidityLockFacet__LiquidityLockedOrDepleted", + "type": "error" + }, + { + "inputs": [], + "name": "LiquidityLockFacet__Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "LiquidityLockFacet__ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "LiquidityTokensUnlocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "LiquidityTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "transferLock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "unlockLiquidityTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506106168061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80635caab6be1461003b578063d586c5f114610050575b600080fd5b61004e610049366004610552565b610063565b005b61004e61005e366004610552565b6102ab565b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff86811685529252909120546009549091168115806100bc575073ffffffffffffffffffffffffffffffffffffffff8316155b8061015357506040517fb25645690000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff82169063b256456990602401602060405180830381865afa15801561012d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101519190610585565b155b1561018a576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83811660008181526012602081815260408084208a8716808652908352818520899055338086529383528185209085529091528083209290925590517f23b872dd0000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915260448101849052908216906323b872dd90606401600060405180830381600087803b15801561023c57600080fd5b505af1158015610250573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff8089168252871660208201527f41f8af339a1fd0d4ed41d2aec5c89989b96536e24958255ed584080bb2c16231935001905060405180910390a150505050565b73ffffffffffffffffffffffffffffffffffffffff81166102f8576040517fd8acced900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003610363576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517fd975dfed0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff90911690600090829063d975dfed90602401602060405180830381865afa1580156103d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fb91906105ae565b6fffffffffffffffffffffffffffffffff16905080600003610449576040517fa03b2b8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fea5ead190000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015283169063ea5ead1990604401600060405180830381600087803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff808a168252881660208201527ff58c2894662c00ada7f78292cc1d18f7de0ff41bf57e6bcb13e7cda455d8a590935001905060405180910390a15050505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461054d57600080fd5b919050565b6000806040838503121561056557600080fd5b61056e83610529565b915061057c60208401610529565b90509250929050565b60006020828403121561059757600080fd5b815180151581146105a757600080fd5b9392505050565b6000602082840312156105c057600080fd5b81516fffffffffffffffffffffffffffffffff811681146105a757600080fdfea2646970667358221220b420a9cc1037c6f5a4821086fb632814f73b6a960c489c70e67ff91bccd1189d64736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80635caab6be1461003b578063d586c5f114610050575b600080fd5b61004e610049366004610552565b610063565b005b61004e61005e366004610552565b6102ab565b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff86811685529252909120546009549091168115806100bc575073ffffffffffffffffffffffffffffffffffffffff8316155b8061015357506040517fb25645690000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff82169063b256456990602401602060405180830381865afa15801561012d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101519190610585565b155b1561018a576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83811660008181526012602081815260408084208a8716808652908352818520899055338086529383528185209085529091528083209290925590517f23b872dd0000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915260448101849052908216906323b872dd90606401600060405180830381600087803b15801561023c57600080fd5b505af1158015610250573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff8089168252871660208201527f41f8af339a1fd0d4ed41d2aec5c89989b96536e24958255ed584080bb2c16231935001905060405180910390a150505050565b73ffffffffffffffffffffffffffffffffffffffff81166102f8576040517fd8acced900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003610363576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517fd975dfed0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff90911690600090829063d975dfed90602401602060405180830381865afa1580156103d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fb91906105ae565b6fffffffffffffffffffffffffffffffff16905080600003610449576040517fa03b2b8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fea5ead190000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015283169063ea5ead1990604401600060405180830381600087803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff808a168252881660208201527ff58c2894662c00ada7f78292cc1d18f7de0ff41bf57e6bcb13e7cda455d8a590935001905060405180910390a15050505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461054d57600080fd5b919050565b6000806040838503121561056557600080fd5b61056e83610529565b915061057c60208401610529565b90509250929050565b60006020828403121561059757600080fd5b815180151581146105a757600080fd5b9392505050565b6000602082840312156105c057600080fd5b81516fffffffffffffffffffffffffffffffff811681146105a757600080fdfea2646970667358221220b420a9cc1037c6f5a4821086fb632814f73b6a960c489c70e67ff91bccd1189d64736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0xA95A3054ceAE176AE4098aA4Ce1a03F2Ca39C4c0" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "LiquidityLockFacet", + "sourceName": "contracts/facets/LiquidityLockFacet.sol", + "abi": [ + { + "inputs": [], + "name": "LiquidityLockFacet__LiquidityLockedOrDepleted", + "type": "error" + }, + { + "inputs": [], + "name": "LiquidityLockFacet__Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "LiquidityLockFacet__ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "LiquidityTokensUnlocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "LiquidityTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "transferLock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "unlockLiquidityTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506106168061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80635caab6be1461003b578063d586c5f114610050575b600080fd5b61004e610049366004610552565b610063565b005b61004e61005e366004610552565b6102ab565b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff86811685529252909120546009549091168115806100bc575073ffffffffffffffffffffffffffffffffffffffff8316155b8061015357506040517fb25645690000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff82169063b256456990602401602060405180830381865afa15801561012d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101519190610585565b155b1561018a576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83811660008181526012602081815260408084208a8716808652908352818520899055338086529383528185209085529091528083209290925590517f23b872dd0000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915260448101849052908216906323b872dd90606401600060405180830381600087803b15801561023c57600080fd5b505af1158015610250573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff8089168252871660208201527f41f8af339a1fd0d4ed41d2aec5c89989b96536e24958255ed584080bb2c16231935001905060405180910390a150505050565b73ffffffffffffffffffffffffffffffffffffffff81166102f8576040517fd8acced900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003610363576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517fd975dfed0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff90911690600090829063d975dfed90602401602060405180830381865afa1580156103d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fb91906105ae565b6fffffffffffffffffffffffffffffffff16905080600003610449576040517fa03b2b8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fea5ead190000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015283169063ea5ead1990604401600060405180830381600087803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff808a168252881660208201527ff58c2894662c00ada7f78292cc1d18f7de0ff41bf57e6bcb13e7cda455d8a590935001905060405180910390a15050505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461054d57600080fd5b919050565b6000806040838503121561056557600080fd5b61056e83610529565b915061057c60208401610529565b90509250929050565b60006020828403121561059757600080fd5b815180151581146105a757600080fd5b9392505050565b6000602082840312156105c057600080fd5b81516fffffffffffffffffffffffffffffffff811681146105a757600080fdfea2646970667358221220b420a9cc1037c6f5a4821086fb632814f73b6a960c489c70e67ff91bccd1189d64736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80635caab6be1461003b578063d586c5f114610050575b600080fd5b61004e610049366004610552565b610063565b005b61004e61005e366004610552565b6102ab565b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff86811685529252909120546009549091168115806100bc575073ffffffffffffffffffffffffffffffffffffffff8316155b8061015357506040517fb25645690000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff82169063b256456990602401602060405180830381865afa15801561012d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101519190610585565b155b1561018a576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83811660008181526012602081815260408084208a8716808652908352818520899055338086529383528185209085529091528083209290925590517f23b872dd0000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915260448101849052908216906323b872dd90606401600060405180830381600087803b15801561023c57600080fd5b505af1158015610250573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff8089168252871660208201527f41f8af339a1fd0d4ed41d2aec5c89989b96536e24958255ed584080bb2c16231935001905060405180910390a150505050565b73ffffffffffffffffffffffffffffffffffffffff81166102f8576040517fd8acced900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260126020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003610363576040517fce94ecd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009546040517fd975dfed0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff90911690600090829063d975dfed90602401602060405180830381865afa1580156103d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fb91906105ae565b6fffffffffffffffffffffffffffffffff16905080600003610449576040517fa03b2b8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fea5ead190000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015283169063ea5ead1990604401600060405180830381600087803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff808a168252881660208201527ff58c2894662c00ada7f78292cc1d18f7de0ff41bf57e6bcb13e7cda455d8a590935001905060405180910390a15050505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461054d57600080fd5b919050565b6000806040838503121561056557600080fd5b61056e83610529565b915061057c60208401610529565b90509250929050565b60006020828403121561059757600080fd5b815180151581146105a757600080fd5b9392505050565b6000602082840312156105c057600080fd5b81516fffffffffffffffffffffffffffffffff811681146105a757600080fdfea2646970667358221220b420a9cc1037c6f5a4821086fb632814f73b6a960c489c70e67ff91bccd1189d64736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0x51F4050319fB89CC8bb609F510e8A8957CD6Ff70" + } +} \ No newline at end of file diff --git a/deployments/OwnershipFacet.json b/deployments/OwnershipFacet.json new file mode 100644 index 0000000..28e0bb6 --- /dev/null +++ b/deployments/OwnershipFacet.json @@ -0,0 +1,166 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "OwnershipFacet", + "sourceName": "contracts/facets/OwnershipFacet.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "owner_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506102be8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80638da5cb5b1461003b578063f2fde38b1461006c575b600080fd5b610043610081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f61007a36600461024b565b6100c6565b005b60006100c17fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b6100ce6100da565b6100d781610191565b50565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461018f577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff8481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60006020828403121561025d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461028157600080fd5b939250505056fea264697066735822122082ef5ed6e9316c1a058ee426f0d22e0c34cb35ca940de73f66fb566239d1e3d264736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80638da5cb5b1461003b578063f2fde38b1461006c575b600080fd5b610043610081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f61007a36600461024b565b6100c6565b005b60006100c17fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b6100ce6100da565b6100d781610191565b50565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461018f577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff8481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60006020828403121561025d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461028157600080fd5b939250505056fea264697066735822122082ef5ed6e9316c1a058ee426f0d22e0c34cb35ca940de73f66fb566239d1e3d264736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0xdC545a73c043e7B507B38e4Dbd68eC2c5B7Ce0C7" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "OwnershipFacet", + "sourceName": "contracts/facets/OwnershipFacet.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "LibDiamond__OnlyOwner", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "owner_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506102be8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80638da5cb5b1461003b578063f2fde38b1461006c575b600080fd5b610043610081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f61007a36600461024b565b6100c6565b005b60006100c17fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b6100ce6100da565b6100d781610191565b50565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461018f577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff8481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60006020828403121561025d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461028157600080fd5b939250505056fea264697066735822122082ef5ed6e9316c1a058ee426f0d22e0c34cb35ca940de73f66fb566239d1e3d264736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80638da5cb5b1461003b578063f2fde38b1461006c575b600080fd5b610043610081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f61007a36600461024b565b6100c6565b005b60006100c17fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b6100ce6100da565b6100d781610191565b50565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205473ffffffffffffffffffffffffffffffffffffffff16331461018f577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054604080517f28803e4700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9092166004830152336024830152519081900360440190fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff8481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60006020828403121561025d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461028157600080fd5b939250505056fea264697066735822122082ef5ed6e9316c1a058ee426f0d22e0c34cb35ca940de73f66fb566239d1e3d264736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": false, + "salt": "" + }, + "address": "0xf0839B96D2063B22F292757D585630C78A6522C0" + } +} \ No newline at end of file diff --git a/deployments/TokenFactoryDiamond.json b/deployments/TokenFactoryDiamond.json new file mode 100644 index 0000000..a1d14d1 --- /dev/null +++ b/deployments/TokenFactoryDiamond.json @@ -0,0 +1,352 @@ +{ + "avalancheFuji": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "TokenFactoryDiamond", + "sourceName": "contracts/TokenFactoryDiamond.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "internalType": "address", + "name": "_diamondCutFacet", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "inputs": [], + "name": "LibDiamond__AddressMustBeZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__FunctionAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__ImmutableFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__IncorrectAction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFacetCode", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LibDiamond__InitializationFailed", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidAddressZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidReplacementWithSameFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__NoSelectors", + "type": "error" + }, + { + "inputs": [], + "name": "TokenFactoryDiamond__InvalidFunction", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_cut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "bytecode": "0x6080604052604051610f98380380610f9883398101604081905261002291610c2d565b61002b82610136565b604080516001808252818301909252600091816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816100425750506040805160018082528183019092529192506000919060208083019080368337019050509050631f931c1c60e01b816000815181106100b1576100b1610c60565b6001600160e01b031990921660209283029190910182015260408051606081019091526001600160a01b038516815290810160008152602001828152508260008151811061010157610101610c60565b602002602001018190525061012d826000604051806020016040528060008152506101b960201b60201c565b50505050610e64565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b03848116918217909355604051600080516020610f78833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60005b83518110156103485760008482815181106101d9576101d9610c60565b6020026020010151602001519050600060028111156101fa576101fa610c76565b81600281111561020c5761020c610c76565b036102605761025b85838151811061022657610226610c60565b60200260200101516000015186848151811061024457610244610c60565b60200260200101516040015161039360201b60201c565b61033f565b600181600281111561027457610274610c76565b036102c35761025b85838151811061028e5761028e610c60565b6020026020010151600001518684815181106102ac576102ac610c60565b60200260200101516040015161053f60201b60201c565b60028160028111156102d7576102d7610c76565b036103265761025b8583815181106102f1576102f1610c60565b60200260200101516000015186848151811061030f5761030f610c60565b6020026020010151604001516106f460201b60201c565b604051636db179c560e11b815260040160405180910390fd5b506001016101bc565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb67383838360405161037c93929190610cdc565b60405180910390a161038e82826107ba565b505050565b80516000036103b55760405163de59c25160e01b815260040160405180910390fd5b600080516020610f788339815191526001600160a01b0383166103eb57604051631f719b2560e11b815260040160405180910390fd5b6001600160a01b0383166000908152600182016020526040812054906001600160601b0382169003610421576104218285610870565b60005b835181101561053857600084828151811061044157610441610c60565b6020908102919091018101516001600160e01b031981166000908152918690526040909120549091506001600160a01b0316801561049257604051637defe32760e11b815260040160405180910390fd5b6001600160e01b0319821660008181526020878152604080832080546001600160a01b03908116600160a01b6001600160601b038c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281546001600160a01b031916179055505060019182019101610424565b5050505050565b80516000036105615760405163de59c25160e01b815260040160405180910390fd5b600080516020610f788339815191526001600160a01b03831661059757604051631f719b2560e11b815260040160405180910390fd5b6001600160a01b0383166000908152600182016020526040812054906001600160601b03821690036105cd576105cd8285610870565b60005b83518110156105385760008482815181106105ed576105ed610c60565b6020908102919091018101516001600160e01b031981166000908152918690526040909120549091506001600160a01b0390811690871681036106435760405163b4a10fbb60e01b815260040160405180910390fd5b61064e8582846108c1565b6001600160e01b0319821660008181526020878152604080832080546001600160a01b03908116600160a01b6001600160601b038c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281546001600160a01b0319161790555050600191820191016105d0565b80516000036107165760405163de59c25160e01b815260040160405180910390fd5b600080516020610f788339815191526001600160a01b0383161561074d57604051639d78f07d60e01b815260040160405180910390fd5b60005b82518110156107b457600083828151811061076d5761076d610c60565b6020908102919091018101516001600160e01b031981166000908152918590526040909120549091506001600160a01b03166107aa8482846108c1565b5050600101610750565b50505050565b6001600160a01b0382166107cc575050565b6107d582610be9565b600080836001600160a01b0316836040516107f09190610ddf565b600060405180830381855af49150503d806000811461082b576040519150601f19603f3d011682016040523d82523d6000602084013e610830565b606091505b5091509150816107b45780511561084a5780518082602001fd5b8383604051634ecac2bb60e01b8152600401610867929190610dfb565b60405180910390fd5b61087981610be9565b6002820180546001600160a01b0390921660008181526001948501602090815260408220860185905594840183559182529290200180546001600160a01b0319169091179055565b6001600160a01b0382166108e857604051635e9bd5a760e01b815260040160405180910390fd5b306001600160a01b0383160361091157604051637897194b60e11b815260040160405180910390fd5b6001600160e01b03198116600090815260208481526040808320546001600160a01b0386168452600180880190935290832054600160a01b9091046001600160601b0316929161096091610e27565b9050808214610a52576001600160a01b0384166000908152600186016020526040812080548390811061099557610995610c60565b600091825260208083206008830401546001600160a01b038916845260018a019091526040909220805460079092166004026101000a90920460e01b9250829190859081106109e6576109e6610c60565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790556001600160e01b03199290921682528690526040902080546001600160a01b0316600160a01b6001600160601b038516021790555b6001600160a01b03841660009081526001860160205260409020805480610a7b57610a7b610e4e565b60008281526020808220600860001990940193840401805463ffffffff600460078716026101000a0219169055919092556001600160e01b03198516825286905260408120819055819003610538576002850154600090610ade90600190610e27565b6001600160a01b0386166000908152600180890160205260409091200154909150808214610b8d576000876002018381548110610b1d57610b1d610c60565b6000918252602090912001546002890180546001600160a01b039092169250829184908110610b4e57610b4e610c60565b600091825260208083209190910180546001600160a01b0319166001600160a01b03948516179055929091168152600189810190925260409020018190555b86600201805480610ba057610ba0610e4e565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0388168252600189810190915260408220015550505050505050565b803b6000819003610c0d576040516331211c7960e11b815260040160405180910390fd5b5050565b80516001600160a01b0381168114610c2857600080fd5b919050565b60008060408385031215610c4057600080fd5b610c4983610c11565b9150610c5760208401610c11565b90509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60005b83811015610ca7578181015183820152602001610c8f565b50506000910152565b60008151808452610cc8816020860160208601610c8c565b601f01601f19169290920160200192915050565b60006060808301606084528087518083526080925060808601915060808160051b8701016020808b0160005b84811015610daf57898403607f19018652815180516001600160a01b03168552838101518986019060038110610d4e57634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b80831015610d9a5783516001600160e01b0319168252928601926001929092019190860190610d70565b50978501979550505090820190600101610d08565b50506001600160a01b038a16908801528681036040880152610dd18189610cb0565b9a9950505050505050505050565b60008251610df1818460208701610c8c565b9190910192915050565b6001600160a01b0383168152604060208201819052600090610e1f90830184610cb0565b949350505050565b81810381811115610e4857634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052603160045260246000fd5b61010580610e736000396000f3fe608060405236600a57005b600080357fffffffff000000000000000000000000000000000000000000000000000000001681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6020819052604090912054819073ffffffffffffffffffffffffffffffffffffffff168060ac576040517f20baa1f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3660008037600080366000845af43d6000803e80801560ca573d6000f35b3d6000fdfea26469706673582212207a8049cb301b22fc38cbf580802d0fd4ff41c642ada0ce80db185ec055b5a27364736f6c63430008190033c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c", + "deployedBytecode": "0x608060405236600a57005b600080357fffffffff000000000000000000000000000000000000000000000000000000001681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6020819052604090912054819073ffffffffffffffffffffffffffffffffffffffff168060ac576040517f20baa1f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3660008037600080366000845af43d6000803e80801560ca573d6000f35b3d6000fdfea26469706673582212207a8049cb301b22fc38cbf580802d0fd4ff41c642ada0ce80db185ec055b5a27364736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [ + "0xb2a30d5D43DE954b32FacefEa17561c51b7baE9B", + "0xDE9F15dc22946BAC9D90Be1116609e5f622E5201" + ], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": true, + "salt": "0x5661706f7246695f546f6b656e466163746f72794469616d6f6e640000000000" + }, + "address": "0x9e6185d0143bD89621C40B04c436098d50E327AC" + }, + "avalanche": { + "artifact": { + "_format": "hh-sol-artifact-1", + "contractName": "TokenFactoryDiamond", + "sourceName": "contracts/TokenFactoryDiamond.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "internalType": "address", + "name": "_diamondCutFacet", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "inputs": [], + "name": "LibDiamond__AddressMustBeZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__FunctionAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__ImmutableFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__IncorrectAction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFacetCode", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InexistentFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LibDiamond__InitializationFailed", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidAddressZero", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__InvalidReplacementWithSameFunction", + "type": "error" + }, + { + "inputs": [], + "name": "LibDiamond__NoSelectors", + "type": "error" + }, + { + "inputs": [], + "name": "TokenFactoryDiamond__InvalidFunction", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_cut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "bytecode": "0x6080604052604051610f98380380610f9883398101604081905261002291610c2d565b61002b82610136565b604080516001808252818301909252600091816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816100425750506040805160018082528183019092529192506000919060208083019080368337019050509050631f931c1c60e01b816000815181106100b1576100b1610c60565b6001600160e01b031990921660209283029190910182015260408051606081019091526001600160a01b038516815290810160008152602001828152508260008151811061010157610101610c60565b602002602001018190525061012d826000604051806020016040528060008152506101b960201b60201c565b50505050610e64565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b03848116918217909355604051600080516020610f78833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60005b83518110156103485760008482815181106101d9576101d9610c60565b6020026020010151602001519050600060028111156101fa576101fa610c76565b81600281111561020c5761020c610c76565b036102605761025b85838151811061022657610226610c60565b60200260200101516000015186848151811061024457610244610c60565b60200260200101516040015161039360201b60201c565b61033f565b600181600281111561027457610274610c76565b036102c35761025b85838151811061028e5761028e610c60565b6020026020010151600001518684815181106102ac576102ac610c60565b60200260200101516040015161053f60201b60201c565b60028160028111156102d7576102d7610c76565b036103265761025b8583815181106102f1576102f1610c60565b60200260200101516000015186848151811061030f5761030f610c60565b6020026020010151604001516106f460201b60201c565b604051636db179c560e11b815260040160405180910390fd5b506001016101bc565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb67383838360405161037c93929190610cdc565b60405180910390a161038e82826107ba565b505050565b80516000036103b55760405163de59c25160e01b815260040160405180910390fd5b600080516020610f788339815191526001600160a01b0383166103eb57604051631f719b2560e11b815260040160405180910390fd5b6001600160a01b0383166000908152600182016020526040812054906001600160601b0382169003610421576104218285610870565b60005b835181101561053857600084828151811061044157610441610c60565b6020908102919091018101516001600160e01b031981166000908152918690526040909120549091506001600160a01b0316801561049257604051637defe32760e11b815260040160405180910390fd5b6001600160e01b0319821660008181526020878152604080832080546001600160a01b03908116600160a01b6001600160601b038c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281546001600160a01b031916179055505060019182019101610424565b5050505050565b80516000036105615760405163de59c25160e01b815260040160405180910390fd5b600080516020610f788339815191526001600160a01b03831661059757604051631f719b2560e11b815260040160405180910390fd5b6001600160a01b0383166000908152600182016020526040812054906001600160601b03821690036105cd576105cd8285610870565b60005b83518110156105385760008482815181106105ed576105ed610c60565b6020908102919091018101516001600160e01b031981166000908152918690526040909120549091506001600160a01b0390811690871681036106435760405163b4a10fbb60e01b815260040160405180910390fd5b61064e8582846108c1565b6001600160e01b0319821660008181526020878152604080832080546001600160a01b03908116600160a01b6001600160601b038c16021782558c168085526001808c0185529285208054938401815585528385206008840401805463ffffffff60079095166004026101000a948502191660e08a901c94909402939093179092559390925287905281546001600160a01b0319161790555050600191820191016105d0565b80516000036107165760405163de59c25160e01b815260040160405180910390fd5b600080516020610f788339815191526001600160a01b0383161561074d57604051639d78f07d60e01b815260040160405180910390fd5b60005b82518110156107b457600083828151811061076d5761076d610c60565b6020908102919091018101516001600160e01b031981166000908152918590526040909120549091506001600160a01b03166107aa8482846108c1565b5050600101610750565b50505050565b6001600160a01b0382166107cc575050565b6107d582610be9565b600080836001600160a01b0316836040516107f09190610ddf565b600060405180830381855af49150503d806000811461082b576040519150601f19603f3d011682016040523d82523d6000602084013e610830565b606091505b5091509150816107b45780511561084a5780518082602001fd5b8383604051634ecac2bb60e01b8152600401610867929190610dfb565b60405180910390fd5b61087981610be9565b6002820180546001600160a01b0390921660008181526001948501602090815260408220860185905594840183559182529290200180546001600160a01b0319169091179055565b6001600160a01b0382166108e857604051635e9bd5a760e01b815260040160405180910390fd5b306001600160a01b0383160361091157604051637897194b60e11b815260040160405180910390fd5b6001600160e01b03198116600090815260208481526040808320546001600160a01b0386168452600180880190935290832054600160a01b9091046001600160601b0316929161096091610e27565b9050808214610a52576001600160a01b0384166000908152600186016020526040812080548390811061099557610995610c60565b600091825260208083206008830401546001600160a01b038916845260018a019091526040909220805460079092166004026101000a90920460e01b9250829190859081106109e6576109e6610c60565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790556001600160e01b03199290921682528690526040902080546001600160a01b0316600160a01b6001600160601b038516021790555b6001600160a01b03841660009081526001860160205260409020805480610a7b57610a7b610e4e565b60008281526020808220600860001990940193840401805463ffffffff600460078716026101000a0219169055919092556001600160e01b03198516825286905260408120819055819003610538576002850154600090610ade90600190610e27565b6001600160a01b0386166000908152600180890160205260409091200154909150808214610b8d576000876002018381548110610b1d57610b1d610c60565b6000918252602090912001546002890180546001600160a01b039092169250829184908110610b4e57610b4e610c60565b600091825260208083209190910180546001600160a01b0319166001600160a01b03948516179055929091168152600189810190925260409020018190555b86600201805480610ba057610ba0610e4e565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0388168252600189810190915260408220015550505050505050565b803b6000819003610c0d576040516331211c7960e11b815260040160405180910390fd5b5050565b80516001600160a01b0381168114610c2857600080fd5b919050565b60008060408385031215610c4057600080fd5b610c4983610c11565b9150610c5760208401610c11565b90509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60005b83811015610ca7578181015183820152602001610c8f565b50506000910152565b60008151808452610cc8816020860160208601610c8c565b601f01601f19169290920160200192915050565b60006060808301606084528087518083526080925060808601915060808160051b8701016020808b0160005b84811015610daf57898403607f19018652815180516001600160a01b03168552838101518986019060038110610d4e57634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b80831015610d9a5783516001600160e01b0319168252928601926001929092019190860190610d70565b50978501979550505090820190600101610d08565b50506001600160a01b038a16908801528681036040880152610dd18189610cb0565b9a9950505050505050505050565b60008251610df1818460208701610c8c565b9190910192915050565b6001600160a01b0383168152604060208201819052600090610e1f90830184610cb0565b949350505050565b81810381811115610e4857634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052603160045260246000fd5b61010580610e736000396000f3fe608060405236600a57005b600080357fffffffff000000000000000000000000000000000000000000000000000000001681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6020819052604090912054819073ffffffffffffffffffffffffffffffffffffffff168060ac576040517f20baa1f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3660008037600080366000845af43d6000803e80801560ca573d6000f35b3d6000fdfea26469706673582212207a8049cb301b22fc38cbf580802d0fd4ff41c642ada0ce80db185ec055b5a27364736f6c63430008190033c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c", + "deployedBytecode": "0x608060405236600a57005b600080357fffffffff000000000000000000000000000000000000000000000000000000001681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6020819052604090912054819073ffffffffffffffffffffffffffffffffffffffff168060ac576040517f20baa1f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3660008037600080366000845af43d6000803e80801560ca573d6000f35b3d6000fdfea26469706673582212207a8049cb301b22fc38cbf580802d0fd4ff41c642ada0ce80db185ec055b5a27364736f6c63430008190033", + "linkReferences": {}, + "deployedLinkReferences": {} + }, + "options": { + "args": [ + "0xCf00c1ac6D26d52054ec89bE6e093F2E270D61d9", + "0x10bbD18FcB1d98aA0F943c01176f2BE4E7c8B782" + ], + "log": true, + "skipIfAlreadyDeployed": true, + "useCreate3Factory": true, + "salt": "0x5661706f7246695f546f6b656e466163746f72794469616d6f6e640000000000" + }, + "address": "0x6Ea0eedC8dD73bBA1A4B6c271AC02154b0d13be2" + } +} \ No newline at end of file diff --git a/deployments/avalancheFuji/.chainId b/deployments/avalancheFuji/.chainId deleted file mode 100644 index a7350c7..0000000 --- a/deployments/avalancheFuji/.chainId +++ /dev/null @@ -1 +0,0 @@ -43113 \ No newline at end of file diff --git a/deployments/avalancheFuji/TokenFactory.json b/deployments/avalancheFuji/TokenFactory.json deleted file mode 100644 index 7579756..0000000 --- a/deployments/avalancheFuji/TokenFactory.json +++ /dev/null @@ -1,1255 +0,0 @@ -{ - "address": "0xd23F764865412E4b1Efe63cAbE2fCbAAA14958f1", - "abi": [ - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "routerAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "stratosphereAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "vaporDexAggregator", - "type": "address" - }, - { - "internalType": "address", - "name": "vaporDexAdapter", - "type": "address" - }, - { - "internalType": "address", - "name": "usdc", - "type": "address" - }, - { - "internalType": "address", - "name": "vape", - "type": "address" - }, - { - "internalType": "uint256", - "name": "launchFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minLiquidityETH", - "type": "uint256" - }, - { - "internalType": "uint40", - "name": "minLockDuration", - "type": "uint40" - }, - { - "internalType": "address", - "name": "sablier", - "type": "address" - }, - { - "internalType": "address", - "name": "nonFungiblePositionManager", - "type": "address" - }, - { - "internalType": "address", - "name": "teamMultisig", - "type": "address" - }, - { - "internalType": "uint256", - "name": "slippage", - "type": "uint256" - } - ], - "internalType": "struct TokenFactory.DeployArgs", - "name": "args", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__InsufficientBalance", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__Invalid", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__LiquidityLockedOrDepleted", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__MinimumLockDuration", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__NotEnoughLiquidity", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "TokenFactory__TranferFailed", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__Unauthorized", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__WrongConstructorArguments", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__WrongLaunchArguments", - "type": "error" - }, - { - "inputs": [], - "name": "TokenFactory__ZeroAddress", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "_to", - "type": "address" - } - ], - "name": "EmergencyWithdraw", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "_newFee", - "type": "uint256" - } - ], - "name": "LaunchFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "pair", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_burner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "LiquidityBurned", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_pairAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_receiver", - "type": "address" - } - ], - "name": "LiquidityTokensUnlocked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_pairAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_to", - "type": "address" - } - ], - "name": "LiquidityTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "_newFee", - "type": "uint256" - } - ], - "name": "MinimumLiquidityETHUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint40", - "name": "_newFee", - "type": "uint40" - } - ], - "name": "MinimumLockDurationUpdated", - "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": "_newSlippage", - "type": "uint256" - } - ], - "name": "SlippageUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "_streamId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_pair", - "type": "address" - } - ], - "name": "StreamCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_tokenAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_creatorAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - } - ], - "name": "TokenLaunched", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "_newAdapter", - "type": "address" - } - ], - "name": "VaporDEXAdapterUpdated", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "address", - "name": "_to", - "type": "address" - } - ], - "name": "emergencyWithdraw", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_counter", - "type": "uint256" - } - ], - "name": "getCounterToAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLaunchFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_pair", - "type": "address" - }, - { - "internalType": "address", - "name": "_owner", - "type": "address" - } - ], - "name": "getLiquidityLock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNonFungiblePositionManager", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getSablier", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getStratosphere", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTeamMultisig", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_owner", - "type": "address" - } - ], - "name": "getTokenLaunch", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getUSDC", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVAPE", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVaporDEXAdapter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVaporDEXFactory", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVaporDEXRouter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVaporDexAdapter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVaporDexAggregator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_name", - "type": "string" - }, - { - "internalType": "string", - "name": "_symbol", - "type": "string" - }, - { - "internalType": "uint256", - "name": "_totalSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_tradingStartsAt", - "type": "uint256" - }, - { - "internalType": "uint40", - "name": "lockDuration", - "type": "uint40" - }, - { - "internalType": "bool", - "name": "_burnLiquidity", - "type": "bool" - } - ], - "name": "launch", - "outputs": [ - { - "internalType": "address", - "name": "_pair", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "streamId", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "minLiquidityETH", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minLockDuration", - "outputs": [ - { - "internalType": "uint40", - "name": "", - "type": "uint40" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_launchFee", - "type": "uint256" - } - ], - "name": "setLaunchFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint40", - "name": "_lockDuration", - "type": "uint40" - } - ], - "name": "setMinLockDuration", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_liquidity", - "type": "uint256" - } - ], - "name": "setMinimumLiquidityETH", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_slippage", - "type": "uint256" - } - ], - "name": "setSlippage", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_vaporDexAdapter", - "type": "address" - } - ], - "name": "setVaporDEXAdapter", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "slippage", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "tokenCounter", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_pair", - "type": "address" - }, - { - "internalType": "address", - "name": "_to", - "type": "address" - } - ], - "name": "transferLock", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_pair", - "type": "address" - }, - { - "internalType": "address", - "name": "_receiver", - "type": "address" - } - ], - "name": "unlockLiquidityTokens", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x2cee6871987089a1a3a2052033084ad5d705ddc6ff653df324607f0c3ffab873", - "receipt": { - "to": null, - "from": "0xb2a30d5D43DE954b32FacefEa17561c51b7baE9B", - "contractAddress": "0xd23F764865412E4b1Efe63cAbE2fCbAAA14958f1", - "transactionIndex": 0, - "gasUsed": "5276354", - "logsBloom": "0x00001000000000000000100000000000000000000000800000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000800020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc401a59a7ac3e262a78301cc87fa7d6972ec221739f6328ec32ccccc5848d119", - "transactionHash": "0x2cee6871987089a1a3a2052033084ad5d705ddc6ff653df324607f0c3ffab873", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 31725521, - "transactionHash": "0x2cee6871987089a1a3a2052033084ad5d705ddc6ff653df324607f0c3ffab873", - "address": "0xd23F764865412E4b1Efe63cAbE2fCbAAA14958f1", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000cf00c1ac6d26d52054ec89be6e093f2e270d61d9" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0xc401a59a7ac3e262a78301cc87fa7d6972ec221739f6328ec32ccccc5848d119" - } - ], - "blockNumber": 31725521, - "cumulativeGasUsed": "5276354", - "status": 1, - "byzantium": true - }, - "args": [ - { - "owner": "0xCf00c1ac6D26d52054ec89bE6e093F2E270D61d9", - "routerAddress": "0x19C0FC4562A4b76F27f86c676eF5a7e38D12a20d", - "stratosphereAddress": "0x65eB37AeB1F2a9cE39556F80044607dD969b0336", - "vaporDexAggregator": "0x55477d8537ede381784b448876AfAa98aa450E63", - "vaporDexAdapter": "0x3F1aF4D92c91511A0BCe4B21bc256bF63bcab470", - "usdc": "0xeA42E3030ab1406a0b6aAd077Caa927673a2c302", - "vape": "0x3bD01B76BB969ef2D5103b5Ea84909AD8d345663", - "launchFee": "1000000", - "minLiquidityETH": "1000000000000000", - "minLockDuration": "1", - "sablier": "0xebf7ed508a0Bb1c4e66b9E6F8C6a73342E7049ac", - "nonFungiblePositionManager": "0x7a0A7C4273B25b3a71Daeaa387c7855081AC4E56", - "teamMultisig": "0xCf00c1ac6D26d52054ec89bE6e093F2E270D61d9", - "slippage": "10000" - } - ], - "numDeployments": 2, - "solcInputHash": "0c06dec9bc6a8c34470ee6e25500a394", - "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"routerAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stratosphereAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"vaporDexAggregator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"vaporDexAdapter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"usdc\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"vape\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"launchFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minLiquidityETH\",\"type\":\"uint256\"},{\"internalType\":\"uint40\",\"name\":\"minLockDuration\",\"type\":\"uint40\"},{\"internalType\":\"address\",\"name\":\"sablier\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nonFungiblePositionManager\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"teamMultisig\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"slippage\",\"type\":\"uint256\"}],\"internalType\":\"struct TokenFactory.DeployArgs\",\"name\":\"args\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__Invalid\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__LiquidityLockedOrDepleted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__MinimumLockDuration\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__NotEnoughLiquidity\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"TokenFactory__TranferFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__Unauthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__WrongConstructorArguments\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__WrongLaunchArguments\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenFactory__ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"EmergencyWithdraw\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_newFee\",\"type\":\"uint256\"}],\"name\":\"LaunchFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"pair\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_burner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityBurned\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_pairAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"LiquidityTokensUnlocked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_pairAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"LiquidityTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_newFee\",\"type\":\"uint256\"}],\"name\":\"MinimumLiquidityETHUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint40\",\"name\":\"_newFee\",\"type\":\"uint40\"}],\"name\":\"MinimumLockDurationUpdated\",\"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\":\"_newSlippage\",\"type\":\"uint256\"}],\"name\":\"SlippageUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_streamId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_pair\",\"type\":\"address\"}],\"name\":\"StreamCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_tokenAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_creatorAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"TokenLaunched\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_newAdapter\",\"type\":\"address\"}],\"name\":\"VaporDEXAdapterUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"emergencyWithdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_counter\",\"type\":\"uint256\"}],\"name\":\"getCounterToAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLaunchFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pair\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"getLiquidityLock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNonFungiblePositionManager\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSablier\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getStratosphere\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTeamMultisig\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"getTokenLaunch\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getUSDC\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVAPE\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVaporDEXAdapter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVaporDEXFactory\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVaporDEXRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVaporDexAdapter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVaporDexAggregator\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tradingStartsAt\",\"type\":\"uint256\"},{\"internalType\":\"uint40\",\"name\":\"lockDuration\",\"type\":\"uint40\"},{\"internalType\":\"bool\",\"name\":\"_burnLiquidity\",\"type\":\"bool\"}],\"name\":\"launch\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"_pair\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"streamId\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minLiquidityETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minLockDuration\",\"outputs\":[{\"internalType\":\"uint40\",\"name\":\"\",\"type\":\"uint40\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_launchFee\",\"type\":\"uint256\"}],\"name\":\"setLaunchFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint40\",\"name\":\"_lockDuration\",\"type\":\"uint40\"}],\"name\":\"setMinLockDuration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_liquidity\",\"type\":\"uint256\"}],\"name\":\"setMinimumLiquidityETH\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_slippage\",\"type\":\"uint256\"}],\"name\":\"setSlippage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_vaporDexAdapter\",\"type\":\"address\"}],\"name\":\"setVaporDEXAdapter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"slippage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tokenCounter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pair\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"transferLock\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pair\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"unlockLiquidityTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Roy & Jose\",\"details\":\"Utilizes 'Sablier' for liquidity locking\",\"errors\":{\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}]},\"kind\":\"dev\",\"methods\":{\"emergencyWithdraw(address,address)\":{\"details\":\"Withdraws any stuck tokens (LP Or USDC) to the specified address.\",\"params\":{\"_to\":\"Address to which the tokens are withdrawn.\",\"_token\":\"Address of the token to be withdrawn.\"}},\"getLaunchFee()\":{\"details\":\"Returns the launch fee.\",\"returns\":{\"_0\":\"uint256 The launch fee.\"}},\"getLiquidityLock(address,address)\":{\"details\":\"Returns the liquidity lock for the specified pair and owner.\",\"params\":{\"_owner\":\"Address of the owner.\",\"_pair\":\"Address of the token pair.\"},\"returns\":{\"_0\":\"uint256 Stream ID for the liquidity lock.\"}},\"getNonFungiblePositionManager()\":{\"details\":\"Returns the address of the NonFungiblePositionManager contract.\",\"returns\":{\"_0\":\"address The address of the NonFungiblePositionManager contract.\"}},\"getSablier()\":{\"details\":\"Returns the address of the Sablier contract.\",\"returns\":{\"_0\":\"address The address of the Sablier contract.\"}},\"getStratosphere()\":{\"details\":\"Returns the address of the Stratosphere contract.\",\"returns\":{\"_0\":\"address The address of the Stratosphere contract.\"}},\"getTeamMultisig()\":{\"details\":\"Returns the address of the team multisig wallet.\",\"returns\":{\"_0\":\"address The address of the team multisig wallet.\"}},\"getUSDC()\":{\"details\":\"Returns the address of the USDC token.\",\"returns\":{\"_0\":\"address The address of the USDC token.\"}},\"getVAPE()\":{\"details\":\"Returns the address of the VAPE token.\",\"returns\":{\"_0\":\"address The address of the VAPE token.\"}},\"getVaporDEXAdapter()\":{\"details\":\"Returns the address of the VaporDEX adapter.\",\"returns\":{\"_0\":\"address The address of the VaporDEX adapter.\"}},\"getVaporDEXFactory()\":{\"details\":\"Returns the address of the VaporDEX factory.\",\"returns\":{\"_0\":\"address The address of the VaporDEX factory.\"}},\"getVaporDEXRouter()\":{\"details\":\"Returns the address of the VaporDEX router.\",\"returns\":{\"_0\":\"address The address of the VaporDEX router.\"}},\"getVaporDexAdapter()\":{\"details\":\"Returns the address of the VaporDEX adapter.\",\"returns\":{\"_0\":\"address The address of the VaporDEX adapter.\"}},\"getVaporDexAggregator()\":{\"details\":\"Returns the address of the VaporDEX aggregator.\",\"returns\":{\"_0\":\"address The address of the VaporDEX aggregator.\"}},\"launch(string,string,uint256,uint256,uint40,bool)\":{\"details\":\"Launches a new token with specified parameters.\",\"params\":{\"_burnLiquidity\":\"Flag indicating whether to burn liquidity or lock it.\",\"_name\":\"Name of the token.\",\"_symbol\":\"Symbol of the token.\",\"_totalSupply\":\"Total supply of the token.\",\"_tradingStartsAt\":\"Timestamp when trading starts for the token.\",\"lockDuration\":\"Number of days to lock liquidity for.\"},\"returns\":{\"_pair\":\"Address of the created token pair.\",\"_tokenAddress\":\"Address of the launched token.\",\"streamId\":\"Stream ID if liquidity is locked, otherwise 0.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"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.\"},\"setLaunchFee(uint256)\":{\"details\":\"Sets the launch fee for creating new tokens.\",\"params\":{\"_launchFee\":\"New launch fee in USDC.\"}},\"setMinLockDuration(uint40)\":{\"details\":\"Sets the minimum liquidity for creating new tokens.\",\"params\":{\"_lockDuration\":\"New lock duration in days.\"}},\"setMinimumLiquidityETH(uint256)\":{\"details\":\"Sets the minimum liquidity for creating new tokens.\",\"params\":{\"_liquidity\":\"New liquidity.\"}},\"setSlippage(uint256)\":{\"details\":\"Sets the minimum liquidity for creating new tokens.\",\"params\":{\"_slippage\":\"New lock duration in days.\"}},\"setVaporDEXAdapter(address)\":{\"details\":\"Sets the VaporDEX adapter address.\",\"params\":{\"_vaporDexAdapter\":\"New VaporDEX adapter address.\"}},\"transferLock(address,address)\":{\"details\":\"Transfers the locked liquidity to the specified recipient for the given pair.\",\"params\":{\"_pair\":\"Address of the token pair.\",\"_to\":\"Address of the recipient.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unlockLiquidityTokens(address,address)\":{\"details\":\"Unlocks liquidity tokens for the specified pair and recipient.\",\"params\":{\"_pair\":\"Address of the token pair.\",\"_receiver\":\"Address of the recipient of unlocked tokens.\"}}},\"title\":\"TokenFactory\",\"version\":1},\"userdoc\":{\"events\":{\"TokenLaunched(address,address,uint256)\":{\"notice\":\"EVENTS ///\"}},\"kind\":\"user\",\"methods\":{\"unlockLiquidityTokens(address,address)\":{\"notice\":\"It is recommended to direct the user to Sablier UI for better error handling.\"}},\"notice\":\"This contract is used to launch new tokens and create liquidity for them\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TokenFactory.sol\":\"TokenFactory\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Context} from \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is set to the address provided by the deployer. This can\\n * later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n /**\\n * @dev The caller account is not authorized to perform an operation.\\n */\\n error OwnableUnauthorizedAccount(address account);\\n\\n /**\\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\\n */\\n error OwnableInvalidOwner(address owner);\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\\n */\\n constructor(address initialOwner) {\\n if (initialOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n if (owner() != _msgSender()) {\\n revert OwnableUnauthorizedAccount(_msgSender());\\n }\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n if (newOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xff6d0bb2e285473e5311d9d3caacb525ae3538a80758c10649a4d61029b017bb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC5267.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\\n\\npragma solidity ^0.8.20;\\n\\ninterface IERC5267 {\\n /**\\n * @dev MAY be emitted to signal that the domain could have changed.\\n */\\n event EIP712DomainChanged();\\n\\n /**\\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\\n * signature.\\n */\\n function eip712Domain()\\n external\\n view\\n returns (\\n bytes1 fields,\\n string memory name,\\n string memory version,\\n uint256 chainId,\\n address verifyingContract,\\n bytes32 salt,\\n uint256[] memory extensions\\n );\\n}\\n\",\"keccak256\":\"0x92aa1df62dc3d33f1656d63bede0923e0df0b706ad4137c8b10b0a8fe549fd92\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC6093.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard ERC20 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\\n */\\ninterface IERC20Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC20InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC20InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `spender`\\u2019s `allowance`. Used in transfers.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC20InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC20InvalidSpender(address spender);\\n}\\n\\n/**\\n * @dev Standard ERC721 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\\n */\\ninterface IERC721Errors {\\n /**\\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\\n * Used in balance queries.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721InvalidOwner(address owner);\\n\\n /**\\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721NonexistentToken(uint256 tokenId);\\n\\n /**\\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param tokenId Identifier number of a token.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC721InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC721InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC721InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC721InvalidOperator(address operator);\\n}\\n\\n/**\\n * @dev Standard ERC1155 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\\n */\\ninterface IERC1155Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC1155InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC1155InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC1155MissingApprovalForAll(address operator, address owner);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC1155InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC1155InvalidOperator(address operator);\\n\\n /**\\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\\n * Used in batch transfers.\\n * @param idsLength Length of the array of token identifiers\\n * @param valuesLength Length of the array of token amounts\\n */\\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\\n}\\n\",\"keccak256\":\"0x60c65f701957fdd6faea1acb0bb45825791d473693ed9ecb34726fdfaa849dd7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"./IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"./extensions/IERC20Metadata.sol\\\";\\nimport {Context} from \\\"../../utils/Context.sol\\\";\\nimport {IERC20Errors} from \\\"../../interfaces/draft-IERC6093.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * The default value of {decimals} is 18. To change this, you should override\\n * this function so it returns a different value.\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n */\\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\\n mapping(address account => uint256) private _balances;\\n\\n mapping(address account => mapping(address spender => uint256))\\n private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the default value returned by this function, unless\\n * it's overridden.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return 18;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `value`.\\n */\\n function transfer(address to, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(\\n address owner,\\n address spender\\n ) public view virtual returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(\\n address spender,\\n uint256 value\\n ) public virtual returns (bool) {\\n address owner = _msgSender();\\n _approve(owner, spender, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `value`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `value`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 value\\n ) public virtual returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, value);\\n _transfer(from, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to`.\\n *\\n * This internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _transfer(address from, address to, uint256 value) internal {\\n if (from == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n if (to == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(from, to, value);\\n }\\n\\n /**\\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\\n * this function.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _update(address from, address to, uint256 value) internal virtual {\\n if (from == address(0)) {\\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\\n _totalSupply += value;\\n } else {\\n uint256 fromBalance = _balances[from];\\n if (fromBalance < value) {\\n revert ERC20InsufficientBalance(from, fromBalance, value);\\n }\\n unchecked {\\n // Overflow not possible: value <= fromBalance <= totalSupply.\\n _balances[from] = fromBalance - value;\\n }\\n }\\n\\n if (to == address(0)) {\\n unchecked {\\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\\n _totalSupply -= value;\\n }\\n } else {\\n unchecked {\\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\\n _balances[to] += value;\\n }\\n }\\n\\n emit Transfer(from, to, value);\\n }\\n\\n /**\\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\\n * Relies on the `_update` mechanism\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _mint(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(address(0), account, value);\\n }\\n\\n /**\\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\\n * Relies on the `_update` mechanism.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead\\n */\\n function _burn(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n _update(account, address(0), value);\\n }\\n\\n /**\\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n *\\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\\n */\\n function _approve(address owner, address spender, uint256 value) internal {\\n _approve(owner, spender, value, true);\\n }\\n\\n /**\\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\\n *\\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\\n * `Approval` event during `transferFrom` operations.\\n *\\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\\n * true using the following override:\\n * ```\\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\\n * super._approve(owner, spender, value, true);\\n * }\\n * ```\\n *\\n * Requirements are the same as {_approve}.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 value,\\n bool emitEvent\\n ) internal virtual {\\n if (owner == address(0)) {\\n revert ERC20InvalidApprover(address(0));\\n }\\n if (spender == address(0)) {\\n revert ERC20InvalidSpender(address(0));\\n }\\n _allowances[owner][spender] = value;\\n if (emitEvent) {\\n emit Approval(owner, spender, value);\\n }\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\\n *\\n * Does not update the allowance value in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Does not emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 value\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n if (currentAllowance < value) {\\n revert ERC20InsufficientAllowance(\\n spender,\\n currentAllowance,\\n value\\n );\\n }\\n unchecked {\\n _approve(owner, spender, currentAllowance - value, false);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x22ddc82ec0ca9b87e340378b0bd956609357f00008e2ade323ee3eece0572b57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xc6a8ff0ea489379b61faa647490411b80102578440ab9d84e9a957cc12164e70\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20Permit} from \\\"./IERC20Permit.sol\\\";\\nimport {ERC20} from \\\"../ERC20.sol\\\";\\nimport {ECDSA} from \\\"../../../utils/cryptography/ECDSA.sol\\\";\\nimport {EIP712} from \\\"../../../utils/cryptography/EIP712.sol\\\";\\nimport {Nonces} from \\\"../../../utils/Nonces.sol\\\";\\n\\n/**\\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\\n bytes32 private constant PERMIT_TYPEHASH =\\n keccak256(\\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\");\\n\\n /**\\n * @dev Permit deadline has expired.\\n */\\n error ERC2612ExpiredSignature(uint256 deadline);\\n\\n /**\\n * @dev Mismatched signature.\\n */\\n error ERC2612InvalidSigner(address signer, address owner);\\n\\n /**\\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\\\"1\\\"`.\\n *\\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\\n */\\n constructor(string memory name) EIP712(name, \\\"1\\\") {}\\n\\n /**\\n * @inheritdoc IERC20Permit\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n if (block.timestamp > deadline) {\\n revert ERC2612ExpiredSignature(deadline);\\n }\\n\\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\\n\\n bytes32 hash = _hashTypedDataV4(structHash);\\n\\n address signer = ECDSA.recover(hash, v, r, s);\\n if (signer != owner) {\\n revert ERC2612InvalidSigner(signer, owner);\\n }\\n\\n _approve(owner, spender, value);\\n }\\n\\n /**\\n * @inheritdoc IERC20Permit\\n */\\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\\n return super.nonces(owner);\\n }\\n\\n /**\\n * @inheritdoc IERC20Permit\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\\n return _domainSeparatorV4();\\n }\\n}\\n\",\"keccak256\":\"0xc858a86a35701004d89022a5e98819aac46ccbdc4072fc9dd43928a676b1a2ee\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0xaa761817f6cd7892fcf158b3c776b34551cde36f48ff9703d53898bc45a94ea2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x6008dabfe393240d73d7dd7688033f72740d570aa422254d29a7dce8568f3aff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC165} from \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\\n * a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\\n * {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\\n * a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the address zero.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x5ef46daa3b58ef2702279d514780316efaa952915ee1aa3396f041ee2982b0b4\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC721} from \\\"../IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x37d1aaaa5a2908a09e9dcf56a26ddf762ecf295afb5964695937344fc6802ce1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n function _contextSuffixLength() internal view virtual returns (uint256) {\\n return 0;\\n }\\n}\\n\",\"keccak256\":\"0x493033a8d1b176a037b2cc6a04dad01a5c157722049bbecf632ca876224dd4b2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Nonces.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\\n */\\nabstract contract Nonces {\\n /**\\n * @dev The nonce used for an `account` is not the expected current nonce.\\n */\\n error InvalidAccountNonce(address account, uint256 currentNonce);\\n\\n mapping(address account => uint256) private _nonces;\\n\\n /**\\n * @dev Returns the next unused nonce for an address.\\n */\\n function nonces(address owner) public view virtual returns (uint256) {\\n return _nonces[owner];\\n }\\n\\n /**\\n * @dev Consumes a nonce.\\n *\\n * Returns the current value and increments nonce.\\n */\\n function _useNonce(address owner) internal virtual returns (uint256) {\\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\\n // decremented or reset. This guarantees that the nonce never overflows.\\n unchecked {\\n // It is important to do x++ and not ++x here.\\n return _nonces[owner]++;\\n }\\n }\\n\\n /**\\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\\n */\\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\\n uint256 current = _useNonce(owner);\\n if (nonce != current) {\\n revert InvalidAccountNonce(owner, current);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0082767004fca261c332e9ad100868327a863a88ef724e844857128845ab350f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/ShortStrings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {StorageSlot} from \\\"./StorageSlot.sol\\\";\\n\\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\\n// | length | 0x BB |\\ntype ShortString is bytes32;\\n\\n/**\\n * @dev This library provides functions to convert short memory strings\\n * into a `ShortString` type that can be used as an immutable variable.\\n *\\n * Strings of arbitrary length can be optimized using this library if\\n * they are short enough (up to 31 bytes) by packing them with their\\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\\n * fallback mechanism can be used for every other case.\\n *\\n * Usage example:\\n *\\n * ```solidity\\n * contract Named {\\n * using ShortStrings for *;\\n *\\n * ShortString private immutable _name;\\n * string private _nameFallback;\\n *\\n * constructor(string memory contractName) {\\n * _name = contractName.toShortStringWithFallback(_nameFallback);\\n * }\\n *\\n * function name() external view returns (string memory) {\\n * return _name.toStringWithFallback(_nameFallback);\\n * }\\n * }\\n * ```\\n */\\nlibrary ShortStrings {\\n // Used as an identifier for strings longer than 31 bytes.\\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\\n\\n error StringTooLong(string str);\\n error InvalidShortString();\\n\\n /**\\n * @dev Encode a string of at most 31 chars into a `ShortString`.\\n *\\n * This will trigger a `StringTooLong` error is the input string is too long.\\n */\\n function toShortString(string memory str) internal pure returns (ShortString) {\\n bytes memory bstr = bytes(str);\\n if (bstr.length > 31) {\\n revert StringTooLong(str);\\n }\\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\\n }\\n\\n /**\\n * @dev Decode a `ShortString` back to a \\\"normal\\\" string.\\n */\\n function toString(ShortString sstr) internal pure returns (string memory) {\\n uint256 len = byteLength(sstr);\\n // using `new string(len)` would work locally but is not memory safe.\\n string memory str = new string(32);\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(str, len)\\n mstore(add(str, 0x20), sstr)\\n }\\n return str;\\n }\\n\\n /**\\n * @dev Return the length of a `ShortString`.\\n */\\n function byteLength(ShortString sstr) internal pure returns (uint256) {\\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\\n if (result > 31) {\\n revert InvalidShortString();\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\\n */\\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\\n if (bytes(value).length < 32) {\\n return toShortString(value);\\n } else {\\n StorageSlot.getStringSlot(store).value = value;\\n return ShortString.wrap(FALLBACK_SENTINEL);\\n }\\n }\\n\\n /**\\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\\n */\\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\\n return toString(value);\\n } else {\\n return store;\\n }\\n }\\n\\n /**\\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\\n * {setWithFallback}.\\n *\\n * WARNING: This will return the \\\"byte length\\\" of the string. This may not reflect the actual length in terms of\\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\\n */\\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\\n return byteLength(value);\\n } else {\\n return bytes(store).length;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x18a7171df639a934592915a520ecb97c5bbc9675a1105607aac8a94e72bf62c6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```solidity\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(newImplementation.code.length > 0);\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n struct StringSlot {\\n string value;\\n }\\n\\n struct BytesSlot {\\n bytes value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\\n */\\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\\n */\\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := store.slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\\n */\\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\\n */\\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := store.slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0x32ba59b4b7299237c8ba56319110989d7978a039faf754793064e967e5894418\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Math} from \\\"./math/Math.sol\\\";\\nimport {SignedMath} from \\\"./math/SignedMath.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant HEX_DIGITS = \\\"0123456789abcdef\\\";\\n uint8 private constant ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev The `value` string doesn't fit in the specified `length`.\\n */\\n error StringsInsufficientHexLength(uint256 value, uint256 length);\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = Math.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\\n */\\n function toStringSigned(int256 value) internal pure returns (string memory) {\\n return string.concat(value < 0 ? \\\"-\\\" : \\\"\\\", toString(SignedMath.abs(value)));\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, Math.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n uint256 localValue = value;\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = HEX_DIGITS[localValue & 0xf];\\n localValue >>= 4;\\n }\\n if (localValue != 0) {\\n revert StringsInsufficientHexLength(value, length);\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\\n * representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\\n }\\n\\n /**\\n * @dev Returns true if the two strings are equal.\\n */\\n function equal(string memory a, string memory b) internal pure returns (bool) {\\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\\n }\\n}\\n\",\"keccak256\":\"0x55f102ea785d8399c0e58d1108e2d289506dde18abc6db1b7f68c1f9f9bc5792\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS\\n }\\n\\n /**\\n * @dev The signature derives the `address(0)`.\\n */\\n error ECDSAInvalidSignature();\\n\\n /**\\n * @dev The signature has an invalid length.\\n */\\n error ECDSAInvalidSignatureLength(uint256 length);\\n\\n /**\\n * @dev The signature has an S value that is in the upper half order.\\n */\\n error ECDSAInvalidSignatureS(bytes32 s);\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\\n * and a bytes32 providing additional information about the error.\\n *\\n * If no error is returned, then the address can be used for verification purposes.\\n *\\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\\n _throwError(error, errorArg);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n */\\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\\n unchecked {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n // We do not check for an overflow here since the shift operation results in 0 or 1.\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n */\\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\\n _throwError(error, errorArg);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError, bytes32) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS, s);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\\n }\\n\\n return (signer, RecoverError.NoError, bytes32(0));\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\\n _throwError(error, errorArg);\\n return recovered;\\n }\\n\\n /**\\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\\n */\\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert ECDSAInvalidSignature();\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert ECDSAInvalidSignatureS(errorArg);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xeed0a08b0b091f528356cbc7245891a4c748682d4f6a18055e8e6ca77d12a6cf\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/EIP712.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {MessageHashUtils} from \\\"./MessageHashUtils.sol\\\";\\nimport {ShortStrings, ShortString} from \\\"../ShortStrings.sol\\\";\\nimport {IERC5267} from \\\"../../interfaces/IERC5267.sol\\\";\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\\n *\\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\\n *\\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\\n * ({_hashTypedDataV4}).\\n *\\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\\n * the chain id to protect against replay attacks on an eventual fork of the chain.\\n *\\n * NOTE: This contract implements the version of the encoding known as \\\"v4\\\", as implemented by the JSON RPC method\\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\\n *\\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\\n *\\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n */\\nabstract contract EIP712 is IERC5267 {\\n using ShortStrings for *;\\n\\n bytes32 private constant TYPE_HASH =\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\");\\n\\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\\n // invalidate the cached domain separator if the chain id changes.\\n bytes32 private immutable _cachedDomainSeparator;\\n uint256 private immutable _cachedChainId;\\n address private immutable _cachedThis;\\n\\n bytes32 private immutable _hashedName;\\n bytes32 private immutable _hashedVersion;\\n\\n ShortString private immutable _name;\\n ShortString private immutable _version;\\n string private _nameFallback;\\n string private _versionFallback;\\n\\n /**\\n * @dev Initializes the domain separator and parameter caches.\\n *\\n * The meaning of `name` and `version` is specified in\\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\\n *\\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\\n * - `version`: the current major version of the signing domain.\\n *\\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\\n * contract upgrade].\\n */\\n constructor(string memory name, string memory version) {\\n _name = name.toShortStringWithFallback(_nameFallback);\\n _version = version.toShortStringWithFallback(_versionFallback);\\n _hashedName = keccak256(bytes(name));\\n _hashedVersion = keccak256(bytes(version));\\n\\n _cachedChainId = block.chainid;\\n _cachedDomainSeparator = _buildDomainSeparator();\\n _cachedThis = address(this);\\n }\\n\\n /**\\n * @dev Returns the domain separator for the current chain.\\n */\\n function _domainSeparatorV4() internal view returns (bytes32) {\\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\\n return _cachedDomainSeparator;\\n } else {\\n return _buildDomainSeparator();\\n }\\n }\\n\\n function _buildDomainSeparator() private view returns (bytes32) {\\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\\n }\\n\\n /**\\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\\n * function returns the hash of the fully encoded EIP712 message for this domain.\\n *\\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\\n *\\n * ```solidity\\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\\n * keccak256(\\\"Mail(address to,string contents)\\\"),\\n * mailTo,\\n * keccak256(bytes(mailContents))\\n * )));\\n * address signer = ECDSA.recover(digest, signature);\\n * ```\\n */\\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\\n }\\n\\n /**\\n * @dev See {IERC-5267}.\\n */\\n function eip712Domain()\\n public\\n view\\n virtual\\n returns (\\n bytes1 fields,\\n string memory name,\\n string memory version,\\n uint256 chainId,\\n address verifyingContract,\\n bytes32 salt,\\n uint256[] memory extensions\\n )\\n {\\n return (\\n hex\\\"0f\\\", // 01111\\n _EIP712Name(),\\n _EIP712Version(),\\n block.chainid,\\n address(this),\\n bytes32(0),\\n new uint256[](0)\\n );\\n }\\n\\n /**\\n * @dev The name parameter for the EIP712 domain.\\n *\\n * NOTE: By default this function reads _name which is an immutable value.\\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function _EIP712Name() internal view returns (string memory) {\\n return _name.toStringWithFallback(_nameFallback);\\n }\\n\\n /**\\n * @dev The version parameter for the EIP712 domain.\\n *\\n * NOTE: By default this function reads _version which is an immutable value.\\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function _EIP712Version() internal view returns (string memory) {\\n return _version.toStringWithFallback(_versionFallback);\\n }\\n}\\n\",\"keccak256\":\"0x999f705a027ed6dc2d4e0df2cc4a509852c6bfd11de1c8161bf88832d0503fd0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Strings} from \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\\n *\\n * The library provides methods for generating a hash of a message that conforms to the\\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\\n * specifications.\\n */\\nlibrary MessageHashUtils {\\n /**\\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\\n * `0x45` (`personal_sign` messages).\\n *\\n * The digest is calculated by prefixing a bytes32 `messageHash` with\\n * `\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\"` and hashing the result. It corresponds with the\\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\\n *\\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\\n * keccak256, although any bytes32 value can be safely used because the final digest will\\n * be re-hashed.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, \\\"\\\\x19Ethereum Signed Message:\\\\n32\\\") // 32 is the bytes-length of messageHash\\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\\n }\\n }\\n\\n /**\\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\\n * `0x45` (`personal_sign` messages).\\n *\\n * The digest is calculated by prefixing an arbitrary `message` with\\n * `\\\"\\\\x19Ethereum Signed Message:\\\\n\\\" + len(message)` and hashing the result. It corresponds with the\\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\\n return\\n keccak256(bytes.concat(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", bytes(Strings.toString(message.length)), message));\\n }\\n\\n /**\\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\\n * `0x00` (data with intended validator).\\n *\\n * The digest is calculated by prefixing an arbitrary `data` with `\\\"\\\\x19\\\\x00\\\"` and the intended\\n * `validator` address. Then hashing the result.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(hex\\\"19_00\\\", validator, data));\\n }\\n\\n /**\\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\\n *\\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\\n * `\\\\x19\\\\x01` and hashing the result. It corresponds to the hash signed by the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, hex\\\"19_01\\\")\\n mstore(add(ptr, 0x02), domainSeparator)\\n mstore(add(ptr, 0x22), structHash)\\n digest := keccak256(ptr, 0x42)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xba333517a3add42cd35fe877656fc3dfcc9de53baa4f3aabbd6d12a92e4ea435\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x4296879f55019b23e135000eb36896057e7101fb7fb859c5ef690cf14643757b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Muldiv operation overflow.\\n */\\n error MathOverflowedMulDiv();\\n\\n enum Rounding {\\n Floor, // Toward negative infinity\\n Ceil, // Toward positive infinity\\n Trunc, // Toward zero\\n Expand // Away from zero\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds towards infinity instead\\n * of rounding towards zero.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (b == 0) {\\n // Guarantee the same behavior as in a regular Solidity division.\\n return a / b;\\n }\\n\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\\n * denominator == 0.\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\\n * Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0 = x * y; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (denominator <= prod1) {\\n revert MathOverflowedMulDiv();\\n }\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\\n\\n uint256 twos = denominator & (0 - denominator);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\\n // works in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\\n * towards zero.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\\n */\\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\\n return uint8(rounding) % 2 == 1;\\n }\\n}\\n\",\"keccak256\":\"0x005ec64c6313f0555d59e278f9a7a5ab2db5bdc72a027f255a37c327af1ec02d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two signed numbers.\\n */\\n function min(int256 a, int256 b) internal pure returns (int256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two signed numbers without overflow.\\n * The result is rounded towards zero.\\n */\\n function average(int256 a, int256 b) internal pure returns (int256) {\\n // Formula from the book \\\"Hacker's Delight\\\"\\n int256 x = (a & b) + ((a ^ b) >> 1);\\n return x + (int256(uint256(x) >> 255) & (a ^ b));\\n }\\n\\n /**\\n * @dev Returns the absolute unsigned value of a signed value.\\n */\\n function abs(int256 n) internal pure returns (uint256) {\\n unchecked {\\n // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x5f7e4076e175393767754387c962926577f1660dd9b810187b9002407656be72\",\"license\":\"MIT\"},\"@prb/math/src/Common.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n// Common.sol\\n//\\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\\n// always operate with SD59x18 and UD60x18 numbers.\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CUSTOM ERRORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\\n\\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\\n\\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\\nerror PRBMath_MulDivSigned_InputTooSmall();\\n\\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CONSTANTS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @dev The maximum value a uint128 number can have.\\nuint128 constant MAX_UINT128 = type(uint128).max;\\n\\n/// @dev The maximum value a uint40 number can have.\\nuint40 constant MAX_UINT40 = type(uint40).max;\\n\\n/// @dev The unit number, which the decimal precision of the fixed-point types.\\nuint256 constant UNIT = 1e18;\\n\\n/// @dev The unit number inverted mod 2^256.\\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\\n\\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\\n/// bit in the binary representation of `UNIT`.\\nuint256 constant UNIT_LPOTD = 262144;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(uint256 x) pure returns (uint256 result) {\\n unchecked {\\n // Start from 0.5 in the 192.64-bit fixed-point format.\\n result = 0x800000000000000000000000000000000000000000000000;\\n\\n // The following logic multiplies the result by $\\\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\\n //\\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\\n // we know that `x & 0xFF` is also 1.\\n if (x & 0xFF00000000000000 > 0) {\\n if (x & 0x8000000000000000 > 0) {\\n result = (result * 0x16A09E667F3BCC909) >> 64;\\n }\\n if (x & 0x4000000000000000 > 0) {\\n result = (result * 0x1306FE0A31B7152DF) >> 64;\\n }\\n if (x & 0x2000000000000000 > 0) {\\n result = (result * 0x1172B83C7D517ADCE) >> 64;\\n }\\n if (x & 0x1000000000000000 > 0) {\\n result = (result * 0x10B5586CF9890F62A) >> 64;\\n }\\n if (x & 0x800000000000000 > 0) {\\n result = (result * 0x1059B0D31585743AE) >> 64;\\n }\\n if (x & 0x400000000000000 > 0) {\\n result = (result * 0x102C9A3E778060EE7) >> 64;\\n }\\n if (x & 0x200000000000000 > 0) {\\n result = (result * 0x10163DA9FB33356D8) >> 64;\\n }\\n if (x & 0x100000000000000 > 0) {\\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000000000 > 0) {\\n if (x & 0x80000000000000 > 0) {\\n result = (result * 0x10058C86DA1C09EA2) >> 64;\\n }\\n if (x & 0x40000000000000 > 0) {\\n result = (result * 0x1002C605E2E8CEC50) >> 64;\\n }\\n if (x & 0x20000000000000 > 0) {\\n result = (result * 0x100162F3904051FA1) >> 64;\\n }\\n if (x & 0x10000000000000 > 0) {\\n result = (result * 0x1000B175EFFDC76BA) >> 64;\\n }\\n if (x & 0x8000000000000 > 0) {\\n result = (result * 0x100058BA01FB9F96D) >> 64;\\n }\\n if (x & 0x4000000000000 > 0) {\\n result = (result * 0x10002C5CC37DA9492) >> 64;\\n }\\n if (x & 0x2000000000000 > 0) {\\n result = (result * 0x1000162E525EE0547) >> 64;\\n }\\n if (x & 0x1000000000000 > 0) {\\n result = (result * 0x10000B17255775C04) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000000000 > 0) {\\n if (x & 0x800000000000 > 0) {\\n result = (result * 0x1000058B91B5BC9AE) >> 64;\\n }\\n if (x & 0x400000000000 > 0) {\\n result = (result * 0x100002C5C89D5EC6D) >> 64;\\n }\\n if (x & 0x200000000000 > 0) {\\n result = (result * 0x10000162E43F4F831) >> 64;\\n }\\n if (x & 0x100000000000 > 0) {\\n result = (result * 0x100000B1721BCFC9A) >> 64;\\n }\\n if (x & 0x80000000000 > 0) {\\n result = (result * 0x10000058B90CF1E6E) >> 64;\\n }\\n if (x & 0x40000000000 > 0) {\\n result = (result * 0x1000002C5C863B73F) >> 64;\\n }\\n if (x & 0x20000000000 > 0) {\\n result = (result * 0x100000162E430E5A2) >> 64;\\n }\\n if (x & 0x10000000000 > 0) {\\n result = (result * 0x1000000B172183551) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00000000 > 0) {\\n if (x & 0x8000000000 > 0) {\\n result = (result * 0x100000058B90C0B49) >> 64;\\n }\\n if (x & 0x4000000000 > 0) {\\n result = (result * 0x10000002C5C8601CC) >> 64;\\n }\\n if (x & 0x2000000000 > 0) {\\n result = (result * 0x1000000162E42FFF0) >> 64;\\n }\\n if (x & 0x1000000000 > 0) {\\n result = (result * 0x10000000B17217FBB) >> 64;\\n }\\n if (x & 0x800000000 > 0) {\\n result = (result * 0x1000000058B90BFCE) >> 64;\\n }\\n if (x & 0x400000000 > 0) {\\n result = (result * 0x100000002C5C85FE3) >> 64;\\n }\\n if (x & 0x200000000 > 0) {\\n result = (result * 0x10000000162E42FF1) >> 64;\\n }\\n if (x & 0x100000000 > 0) {\\n result = (result * 0x100000000B17217F8) >> 64;\\n }\\n }\\n\\n if (x & 0xFF000000 > 0) {\\n if (x & 0x80000000 > 0) {\\n result = (result * 0x10000000058B90BFC) >> 64;\\n }\\n if (x & 0x40000000 > 0) {\\n result = (result * 0x1000000002C5C85FE) >> 64;\\n }\\n if (x & 0x20000000 > 0) {\\n result = (result * 0x100000000162E42FF) >> 64;\\n }\\n if (x & 0x10000000 > 0) {\\n result = (result * 0x1000000000B17217F) >> 64;\\n }\\n if (x & 0x8000000 > 0) {\\n result = (result * 0x100000000058B90C0) >> 64;\\n }\\n if (x & 0x4000000 > 0) {\\n result = (result * 0x10000000002C5C860) >> 64;\\n }\\n if (x & 0x2000000 > 0) {\\n result = (result * 0x1000000000162E430) >> 64;\\n }\\n if (x & 0x1000000 > 0) {\\n result = (result * 0x10000000000B17218) >> 64;\\n }\\n }\\n\\n if (x & 0xFF0000 > 0) {\\n if (x & 0x800000 > 0) {\\n result = (result * 0x1000000000058B90C) >> 64;\\n }\\n if (x & 0x400000 > 0) {\\n result = (result * 0x100000000002C5C86) >> 64;\\n }\\n if (x & 0x200000 > 0) {\\n result = (result * 0x10000000000162E43) >> 64;\\n }\\n if (x & 0x100000 > 0) {\\n result = (result * 0x100000000000B1721) >> 64;\\n }\\n if (x & 0x80000 > 0) {\\n result = (result * 0x10000000000058B91) >> 64;\\n }\\n if (x & 0x40000 > 0) {\\n result = (result * 0x1000000000002C5C8) >> 64;\\n }\\n if (x & 0x20000 > 0) {\\n result = (result * 0x100000000000162E4) >> 64;\\n }\\n if (x & 0x10000 > 0) {\\n result = (result * 0x1000000000000B172) >> 64;\\n }\\n }\\n\\n if (x & 0xFF00 > 0) {\\n if (x & 0x8000 > 0) {\\n result = (result * 0x100000000000058B9) >> 64;\\n }\\n if (x & 0x4000 > 0) {\\n result = (result * 0x10000000000002C5D) >> 64;\\n }\\n if (x & 0x2000 > 0) {\\n result = (result * 0x1000000000000162E) >> 64;\\n }\\n if (x & 0x1000 > 0) {\\n result = (result * 0x10000000000000B17) >> 64;\\n }\\n if (x & 0x800 > 0) {\\n result = (result * 0x1000000000000058C) >> 64;\\n }\\n if (x & 0x400 > 0) {\\n result = (result * 0x100000000000002C6) >> 64;\\n }\\n if (x & 0x200 > 0) {\\n result = (result * 0x10000000000000163) >> 64;\\n }\\n if (x & 0x100 > 0) {\\n result = (result * 0x100000000000000B1) >> 64;\\n }\\n }\\n\\n if (x & 0xFF > 0) {\\n if (x & 0x80 > 0) {\\n result = (result * 0x10000000000000059) >> 64;\\n }\\n if (x & 0x40 > 0) {\\n result = (result * 0x1000000000000002C) >> 64;\\n }\\n if (x & 0x20 > 0) {\\n result = (result * 0x10000000000000016) >> 64;\\n }\\n if (x & 0x10 > 0) {\\n result = (result * 0x1000000000000000B) >> 64;\\n }\\n if (x & 0x8 > 0) {\\n result = (result * 0x10000000000000006) >> 64;\\n }\\n if (x & 0x4 > 0) {\\n result = (result * 0x10000000000000003) >> 64;\\n }\\n if (x & 0x2 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n if (x & 0x1 > 0) {\\n result = (result * 0x10000000000000001) >> 64;\\n }\\n }\\n\\n // In the code snippet below, two operations are executed simultaneously:\\n //\\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\\n //\\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\\n // integer part, $2^n$.\\n result *= UNIT;\\n result >>= (191 - (x >> 64));\\n }\\n}\\n\\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\\n///\\n/// @dev See the note on \\\"msb\\\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\\n///\\n/// Each step in this implementation is equivalent to this high-level code:\\n///\\n/// ```solidity\\n/// if (x >= 2 ** 128) {\\n/// x >>= 128;\\n/// result += 128;\\n/// }\\n/// ```\\n///\\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\\n///\\n/// The Yul instructions used below are:\\n///\\n/// - \\\"gt\\\" is \\\"greater than\\\"\\n/// - \\\"or\\\" is the OR bitwise operator\\n/// - \\\"shl\\\" is \\\"shift left\\\"\\n/// - \\\"shr\\\" is \\\"shift right\\\"\\n///\\n/// @param x The uint256 number for which to find the index of the most significant bit.\\n/// @return result The index of the most significant bit as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction msb(uint256 x) pure returns (uint256 result) {\\n // 2^128\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^64\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^32\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(5, gt(x, 0xFFFFFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^16\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(4, gt(x, 0xFFFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^8\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(3, gt(x, 0xFF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^4\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(2, gt(x, 0xF))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^2\\n assembly (\\\"memory-safe\\\") {\\n let factor := shl(1, gt(x, 0x3))\\n x := shr(factor, x)\\n result := or(result, factor)\\n }\\n // 2^1\\n // No need to shift x any more.\\n assembly (\\\"memory-safe\\\") {\\n let factor := gt(x, 0x1)\\n result := or(result, factor)\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - The denominator must not be zero.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as a uint256.\\n/// @param y The multiplier as a uint256.\\n/// @param denominator The divisor as a uint256.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / denominator;\\n }\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (prod1 >= denominator) {\\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\\n }\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // 512 by 256 division\\n ////////////////////////////////////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n // Compute remainder using the mulmod Yul instruction.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512-bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n unchecked {\\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\\n uint256 lpotdod = denominator & (~denominator + 1);\\n uint256 flippedLpotdod;\\n\\n assembly (\\\"memory-safe\\\") {\\n // Factor powers of two out of denominator.\\n denominator := div(denominator, lpotdod)\\n\\n // Divide [prod1 prod0] by lpotdod.\\n prod0 := div(prod0, lpotdod)\\n\\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * flippedLpotdod;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f71e18 with 512-bit precision.\\n///\\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\\n///\\n/// Notes:\\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\\n/// - The result is rounded toward zero.\\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\\n///\\n/// $$\\n/// \\\\begin{cases}\\n/// x * y = MAX\\\\_UINT256 * UNIT \\\\\\\\\\n/// (x * y) \\\\% UNIT \\\\geq \\\\frac{UNIT}{2}\\n/// \\\\end{cases}\\n/// $$\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - The result must fit in uint256.\\n///\\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\\n uint256 prod0;\\n uint256 prod1;\\n assembly (\\\"memory-safe\\\") {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n if (prod1 == 0) {\\n unchecked {\\n return prod0 / UNIT;\\n }\\n }\\n\\n if (prod1 >= UNIT) {\\n revert PRBMath_MulDiv18_Overflow(x, y);\\n }\\n\\n uint256 remainder;\\n assembly (\\\"memory-safe\\\") {\\n remainder := mulmod(x, y, UNIT)\\n result :=\\n mul(\\n or(\\n div(sub(prod0, remainder), UNIT_LPOTD),\\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\\n ),\\n UNIT_INVERSE\\n )\\n }\\n}\\n\\n/// @notice Calculates x*y\\u00f7denominator with 512-bit precision.\\n///\\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {mulDiv}.\\n/// - None of the inputs can be `type(int256).min`.\\n/// - The result must fit in int256.\\n///\\n/// @param x The multiplicand as an int256.\\n/// @param y The multiplier as an int256.\\n/// @param denominator The divisor as an int256.\\n/// @return result The result as an int256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\\n revert PRBMath_MulDivSigned_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x, y and the denominator.\\n uint256 xAbs;\\n uint256 yAbs;\\n uint256 dAbs;\\n unchecked {\\n xAbs = x < 0 ? uint256(-x) : uint256(x);\\n yAbs = y < 0 ? uint256(-y) : uint256(y);\\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\\n }\\n\\n // Compute the absolute value of x*y\\u00f7denominator. The result must fit in int256.\\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\\n if (resultAbs > uint256(type(int256).max)) {\\n revert PRBMath_MulDivSigned_Overflow(x, y);\\n }\\n\\n // Get the signs of x, y and the denominator.\\n uint256 sx;\\n uint256 sy;\\n uint256 sd;\\n assembly (\\\"memory-safe\\\") {\\n // \\\"sgt\\\" is the \\\"signed greater than\\\" assembly instruction and \\\"sub(0,1)\\\" is -1 in two's complement.\\n sx := sgt(x, sub(0, 1))\\n sy := sgt(y, sub(0, 1))\\n sd := sgt(denominator, sub(0, 1))\\n }\\n\\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\\n // If there are, the result should be negative. Otherwise, it should be positive.\\n unchecked {\\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - If x is not a perfect square, the result is rounded down.\\n/// - Credits to OpenZeppelin for the explanations in comments below.\\n///\\n/// @param x The uint256 number for which to calculate the square root.\\n/// @return result The result as a uint256.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(uint256 x) pure returns (uint256 result) {\\n if (x == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of x is a power of 2 such that we have:\\n //\\n // $$\\n // msb(x) <= x <= 2*msb(x)$\\n // $$\\n //\\n // We write $msb(x)$ as $2^k$, and we get:\\n //\\n // $$\\n // k = log_2(x)\\n // $$\\n //\\n // Thus, we can write the initial inequality as:\\n //\\n // $$\\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\\\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\\\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\\n // $$\\n //\\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\\n uint256 xAux = uint256(x);\\n result = 1;\\n if (xAux >= 2 ** 128) {\\n xAux >>= 128;\\n result <<= 64;\\n }\\n if (xAux >= 2 ** 64) {\\n xAux >>= 64;\\n result <<= 32;\\n }\\n if (xAux >= 2 ** 32) {\\n xAux >>= 32;\\n result <<= 16;\\n }\\n if (xAux >= 2 ** 16) {\\n xAux >>= 16;\\n result <<= 8;\\n }\\n if (xAux >= 2 ** 8) {\\n xAux >>= 8;\\n result <<= 4;\\n }\\n if (xAux >= 2 ** 4) {\\n xAux >>= 4;\\n result <<= 2;\\n }\\n if (xAux >= 2 ** 2) {\\n result <<= 1;\\n }\\n\\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\\n // precision into the expected uint128 result.\\n unchecked {\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n result = (result + x / result) >> 1;\\n\\n // If x is not a perfect square, round the result toward zero.\\n uint256 roundedResult = x / result;\\n if (result >= roundedResult) {\\n result = roundedResult;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaa374e2c26cc93e8c22a6953804ee05f811597ef5fa82f76824378b22944778b\",\"license\":\"MIT\"},\"@prb/math/src/UD2x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud2x18/Casting.sol\\\";\\nimport \\\"./ud2x18/Constants.sol\\\";\\nimport \\\"./ud2x18/Errors.sol\\\";\\nimport \\\"./ud2x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xfb624e24cd8bb790fa08e7827819de85504a86e20e961fa4ad126c65b6d90641\",\"license\":\"MIT\"},\"@prb/math/src/UD60x18.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\n/*\\n\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u255a\\u2550\\u2550\\u2588\\u2588\\u2554\\u2550\\u2550\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u2588\\u2588\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2551\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u255a\\u2550\\u255d \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\n\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d\\n\\n\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2588\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2550\\u255d \\u2588\\u2588\\u2554\\u2550\\u2588\\u2588\\u2588\\u2588\\u2557\\u255a\\u2588\\u2588\\u2557\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2588\\u2588\\u2551 \\u255a\\u2588\\u2588\\u2588\\u2554\\u255d \\u255a\\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2550\\u2588\\u2588\\u2557\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2551 \\u2588\\u2588\\u2554\\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u2588\\u2588\\u2554\\u2550\\u2550\\u2588\\u2588\\u2557\\n\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\u2588\\u2588\\u2554\\u255d \\u2588\\u2588\\u2557 \\u2588\\u2588\\u2551\\u255a\\u2588\\u2588\\u2588\\u2588\\u2588\\u2554\\u255d\\n \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u255d \\u255a\\u2550\\u2550\\u2550\\u2550\\u255d\\n\\n*/\\n\\nimport \\\"./ud60x18/Casting.sol\\\";\\nimport \\\"./ud60x18/Constants.sol\\\";\\nimport \\\"./ud60x18/Conversions.sol\\\";\\nimport \\\"./ud60x18/Errors.sol\\\";\\nimport \\\"./ud60x18/Helpers.sol\\\";\\nimport \\\"./ud60x18/Math.sol\\\";\\nimport \\\"./ud60x18/ValueType.sol\\\";\\n\",\"keccak256\":\"0xb98c6f74275914d279e8af6c502c2b1f50d5f6e1ed418d3b0153f5a193206c48\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD1x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD2x18.\\n/// - x must be positive.\\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\\n }\\n result = UD2x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\\n }\\n result = uint256(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\\n }\\n result = uint128(uint64(xInt));\\n}\\n\\n/// @notice Casts an SD1x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\\n int64 xInt = SD1x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\\n }\\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\\n }\\n result = uint40(uint64(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD1x18 number into int64.\\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\\n result = SD1x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int64 number into SD1x18.\\nfunction wrap(int64 x) pure returns (SD1x18 result) {\\n result = SD1x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9e49e2b37c1bb845861740805edaaef3fe951a7b96eef16ce84fbf76e8278670\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as an SD1x18 number.\\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\\n\\n/// @dev The maximum value an SD1x18 number can have.\\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\\n\\n/// @dev PI as an SD1x18 number.\\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD1x18.\\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\\nint256 constant uUNIT = 1e18;\\n\",\"keccak256\":\"0xb51aab4a2ea76f530dccbf3b7d4af24c8f3ceef67f3c574b58650466ea924a3f\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD1x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\\n\\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\\n\",\"keccak256\":\"0x836cb42ba619ca369fd4765bc47fefc3c3621369c5861882af14660aca5057ee\",\"license\":\"MIT\"},\"@prb/math/src/sd1x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype SD1x18 is int64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD59x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD1x18 global;\\n\",\"keccak256\":\"0x2f86f1aa9fca42f40808b51a879b406ac51817647bdb9642f8a79dd8fdb754a7\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts an SD59x18 number into int256.\\n/// @dev This is basically a functional alias for {unwrap}.\\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Casts an SD59x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be greater than or equal to `uMIN_SD1x18`.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < uMIN_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\\n }\\n if (xInt > uMAX_SD1x18) {\\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\\n }\\n if (xInt > int256(uint256(uMAX_UD2x18))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(uint256(xInt)));\\n}\\n\\n/// @notice Casts an SD59x18 number into UD60x18.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\\n }\\n result = UD60x18.wrap(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint256.\\n/// @dev Requirements:\\n/// - x must be positive.\\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\\n }\\n result = uint256(xInt);\\n}\\n\\n/// @notice Casts an SD59x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `uMAX_UINT128`.\\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT128))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(uint256(xInt));\\n}\\n\\n/// @notice Casts an SD59x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be positive.\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\\n int256 xInt = SD59x18.unwrap(x);\\n if (xInt < 0) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\\n }\\n if (xInt > int256(uint256(MAX_UINT40))) {\\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(uint256(xInt));\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\\n/// @notice Unwraps an SD59x18 number into int256.\\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\\n result = SD59x18.unwrap(x);\\n}\\n\\n/// @notice Wraps an int256 number into SD59x18.\\nfunction wrap(int256 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x3b21b60ec2998c3ae32f647412da51d3683b3f183a807198cc8d157499484f99\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as an SD59x18 number.\\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Half the UNIT number.\\nint256 constant uHALF_UNIT = 0.5e18;\\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as an SD59x18 number.\\nint256 constant uLOG2_10 = 3_321928094887362347;\\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as an SD59x18 number.\\nint256 constant uLOG2_E = 1_442695040888963407;\\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value an SD59x18 number can have.\\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\\n\\n/// @dev The maximum whole value an SD59x18 number can have.\\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\\n\\n/// @dev The minimum value an SD59x18 number can have.\\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\\n\\n/// @dev The minimum whole value an SD59x18 number can have.\\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\\n\\n/// @dev PI as an SD59x18 number.\\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of SD59x18.\\nint256 constant uUNIT = 1e18;\\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\\n\\n/// @dev The unit number squared.\\nint256 constant uUNIT_SQUARED = 1e36;\\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as an SD59x18 number.\\nSD59x18 constant ZERO = SD59x18.wrap(0);\\n\",\"keccak256\":\"0xe0a1ca1a7b5b2d637cff83a8caa3d2e67a6a34f7ee9df58a9ca5d5fa268c474a\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Abs_MinSD59x18();\\n\\n/// @notice Thrown when ceiling a number overflows SD59x18.\\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\\n\\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Div_InputTooSmall();\\n\\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\\n\\n/// @notice Thrown when flooring a number underflows SD59x18.\\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\\n\\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\\nerror PRBMath_SD59x18_Mul_InputTooSmall();\\n\\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\\n\\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\\n\\n/// @notice Thrown when taking the square root of a negative number.\\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\\n\\n/// @notice Thrown when the calculating the square root overflows SD59x18.\\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\\n\",\"keccak256\":\"0xa6d00fe5efa215ac0df25c896e3da99a12fb61e799644b2ec32da947313d3db4\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n return wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal (=) operation in the SD59x18 type.\\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the SD59x18 type.\\nfunction isZero(SD59x18 x) pure returns (bool result) {\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(-x.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\\n unchecked {\\n result = wrap(-x.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0x208570f1657cf730cb6c3d81aa14030e0d45cf906cdedea5059369d7df4bb716\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_SD59x18,\\n uMAX_WHOLE_SD59x18,\\n uMIN_SD59x18,\\n uMIN_WHOLE_SD59x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { wrap } from \\\"./Helpers.sol\\\";\\nimport { SD59x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Calculates the absolute value of x.\\n///\\n/// @dev Requirements:\\n/// - x must be greater than `MIN_SD59x18`.\\n///\\n/// @param x The SD59x18 number for which to calculate the absolute value.\\n/// @param result The absolute value of x as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\\n }\\n result = xInt < 0 ? wrap(-xInt) : x;\\n}\\n\\n/// @notice Calculates the arithmetic average of x and y.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The arithmetic average as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n unchecked {\\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\\n int256 sum = (xInt >> 1) + (yInt >> 1);\\n\\n if (sum < 0) {\\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\\n assembly (\\\"memory-safe\\\") {\\n result := add(sum, and(or(xInt, yInt), 1))\\n }\\n } else {\\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\\n result = wrap(sum + (xInt & yInt & 1));\\n }\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt > uMAX_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt > 0) {\\n resultInt += uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\\n///\\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\\n/// values separately.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The denominator must not be zero.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The numerator as an SD59x18 number.\\n/// @param y The denominator as an SD59x18 number.\\n/// @param result The quotient as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*UNIT\\u00f7y). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}.\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xInt > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n int256 doubleUnitProduct = xInt * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\\n///\\n/// $$\\n/// 2^{-x} = \\\\frac{1}{2^x}\\n/// $$\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\\n///\\n/// Notes:\\n/// - If x is less than -59_794705707972522261, the result is zero.\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The exponent as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n // The inverse of any number less than this is truncated to zero.\\n if (xInt < -59_794705707972522261) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Inline the fixed-point inversion to save gas.\\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\\n }\\n } else {\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xInt > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\\n\\n // It is safe to cast the result to int256 due to the checks above.\\n result = wrap(int256(Common.exp2(x_192x64)));\\n }\\n }\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n///\\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\\n///\\n/// @param x The SD59x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < uMIN_WHOLE_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\\n }\\n\\n int256 remainder = xInt % uUNIT;\\n if (remainder == 0) {\\n result = x;\\n } else {\\n unchecked {\\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\\n int256 resultInt = xInt - remainder;\\n if (xInt < 0) {\\n resultInt -= uUNIT;\\n }\\n result = wrap(resultInt);\\n }\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\\n/// of the radix point for negative numbers.\\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\\n/// @param x The SD59x18 number to get the fractional part of.\\n/// @param result The fractional part of x as an SD59x18 number.\\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(x.unwrap() % uUNIT);\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x * y must fit in SD59x18.\\n/// - x * y must not be negative, since complex numbers are not supported.\\n///\\n/// @param x The first operand as an SD59x18 number.\\n/// @param y The second operand as an SD59x18 number.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == 0 || yInt == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\\n int256 xyInt = xInt * yInt;\\n if (xyInt / xInt != yInt) {\\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\\n }\\n\\n // The product must not be negative, since complex numbers are not supported.\\n if (xyInt < 0) {\\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n uint256 resultUint = Common.sqrt(uint256(xyInt));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the inverse.\\n/// @return result The inverse as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~195_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The SD59x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n default { result := uMAX_SD59x18 }\\n }\\n\\n if (result.unwrap() == uMAX_SD59x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt <= 0) {\\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n int256 sign;\\n if (xInt >= uUNIT) {\\n sign = 1;\\n } else {\\n sign = -1;\\n // Inline the fixed-point inversion to save gas.\\n xInt = uUNIT_SQUARED / xInt;\\n }\\n\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(uint256(xInt / uUNIT));\\n\\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\\n int256 resultInt = int256(n) * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n int256 y = xInt >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultInt * sign);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n int256 DOUBLE_UNIT = 2e18;\\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultInt = resultInt + delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n resultInt *= sign;\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv18}.\\n/// - None of the inputs can be `MIN_SD59x18`.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The multiplicand as an SD59x18 number.\\n/// @param y The multiplier as an SD59x18 number.\\n/// @return result The product as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\\n }\\n\\n // Get hold of the absolute values of x and y.\\n uint256 xAbs;\\n uint256 yAbs;\\n unchecked {\\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\\n }\\n\\n // Compute the absolute value (x*y\\u00f7UNIT). The resulting value must fit in SD59x18.\\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\\n }\\n\\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\\n // negative, 0 for positive or zero).\\n bool sameSign = (xInt ^ yInt) > -1;\\n\\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\\n unchecked {\\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\\n }\\n}\\n\\n/// @notice Raises x to the power of y using the following formula:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y Exponent to raise x to, as an SD59x18 number\\n/// @return result x raised to power y, as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n int256 yInt = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xInt == 0) {\\n return yInt == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xInt == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yInt == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yInt == uUNIT) {\\n return x;\\n }\\n\\n // Calculate the result using the formula.\\n result = exp2(mul(log2(x), y));\\n}\\n\\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\\n/// - The result must fit in SD59x18.\\n///\\n/// @param x The base as an SD59x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\\n uint256 xAbs = uint256(abs(x).unwrap());\\n\\n // Calculate the first iteration of the loop in advance.\\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n uint256 yAux = y;\\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\\n xAbs = Common.mulDiv18(xAbs, xAbs);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (yAux & 1 > 0) {\\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\\n }\\n }\\n\\n // The result must fit in SD59x18.\\n if (resultAbs > uint256(uMAX_SD59x18)) {\\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\\n }\\n\\n unchecked {\\n // Is the base negative and the exponent odd? If yes, the result should be negative.\\n int256 resultInt = int256(resultAbs);\\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\\n if (isNegative) {\\n resultInt = -resultInt;\\n }\\n result = wrap(resultInt);\\n }\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - Only the positive root is returned.\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x cannot be negative, since complex numbers are not supported.\\n/// - x must be less than `MAX_SD59x18 / UNIT`.\\n///\\n/// @param x The SD59x18 number for which to calculate the square root.\\n/// @return result The result as an SD59x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\\n int256 xInt = x.unwrap();\\n if (xInt < 0) {\\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\\n }\\n if (xInt > uMAX_SD59x18 / uUNIT) {\\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\\n }\\n\\n unchecked {\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\\n // In this case, the two numbers are both the square root.\\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\\n result = wrap(int256(resultUint));\\n }\\n}\\n\",\"keccak256\":\"0xedd0635769176ab99878a91ce267cee2ca107b30e6b0db10736573ff4d102868\",\"license\":\"MIT\"},\"@prb/math/src/sd59x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type int256.\\ntype SD59x18 is int256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoInt256,\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Math.abs,\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.log10,\\n Math.log2,\\n Math.ln,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.uncheckedUnary,\\n Helpers.xor\\n} for SD59x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the SD59x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.or as |,\\n Helpers.sub as -,\\n Helpers.unary as -,\\n Helpers.xor as ^\\n} for SD59x18 global;\\n\",\"keccak256\":\"0xe03112d145dcd5863aff24e5f381debaae29d446acd5666f3d640e3d9af738d7\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"../ud60x18/ValueType.sol\\\";\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD2x18 number into SD1x18.\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(uMAX_SD1x18)) {\\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(xUint));\\n}\\n\\n/// @notice Casts a UD2x18 number into SD59x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\\n}\\n\\n/// @notice Casts a UD2x18 number into UD60x18.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint128.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\\n result = uint128(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint256.\\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\\n result = uint256(UD2x18.unwrap(x));\\n}\\n\\n/// @notice Casts a UD2x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\\n uint64 xUint = UD2x18.unwrap(x);\\n if (xUint > uint64(Common.MAX_UINT40)) {\\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\\n/// @notice Unwrap a UD2x18 number into uint64.\\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\\n result = UD2x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint64 number into UD2x18.\\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\\n result = UD2x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x9b1a35d432ef951a415fae8098b3c609a99b630a3d5464b3c8e1efa8893eea07\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @dev Euler's number as a UD2x18 number.\\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum value a UD2x18 number can have.\\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\\n\\n/// @dev PI as a UD2x18 number.\\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD2x18.\\nuint256 constant uUNIT = 1e18;\\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\\n\",\"keccak256\":\"0xbd11da8ad79ffc8b7b8244c82632b0ca31970e190a8877ba1a69b4b8065dcea5\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD2x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\\n\\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\\n\",\"keccak256\":\"0xdf1e22f0b4c8032bcc8b7f63fe3984e1387f3dc7b2e9ab381822249f75376d33\",\"license\":\"MIT\"},\"@prb/math/src/ud2x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\n\\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\\n/// storage.\\ntype UD2x18 is uint64;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoSD59x18,\\n Casting.intoUD60x18,\\n Casting.intoUint256,\\n Casting.intoUint128,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD2x18 global;\\n\",\"keccak256\":\"0x2802edc9869db116a0b5c490cc5f8554742f747183fa30ac5e9c80bb967e61a1\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Casting.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Errors.sol\\\" as CastingErrors;\\nimport { MAX_UINT128, MAX_UINT40 } from \\\"../Common.sol\\\";\\nimport { uMAX_SD1x18 } from \\\"../sd1x18/Constants.sol\\\";\\nimport { SD1x18 } from \\\"../sd1x18/ValueType.sol\\\";\\nimport { uMAX_SD59x18 } from \\\"../sd59x18/Constants.sol\\\";\\nimport { SD59x18 } from \\\"../sd59x18/ValueType.sol\\\";\\nimport { uMAX_UD2x18 } from \\\"../ud2x18/Constants.sol\\\";\\nimport { UD2x18 } from \\\"../ud2x18/ValueType.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Casts a UD60x18 number into SD1x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD1x18`.\\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(int256(uMAX_SD1x18))) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\\n }\\n result = SD1x18.wrap(int64(uint64(xUint)));\\n}\\n\\n/// @notice Casts a UD60x18 number into UD2x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_UD2x18`.\\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uMAX_UD2x18) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\\n }\\n result = UD2x18.wrap(uint64(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into SD59x18.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `uMAX_SD59x18`.\\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > uint256(uMAX_SD59x18)) {\\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\\n }\\n result = SD59x18.wrap(int256(xUint));\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev This is basically an alias for {unwrap}.\\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint128.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT128`.\\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT128) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\\n }\\n result = uint128(xUint);\\n}\\n\\n/// @notice Casts a UD60x18 number into uint40.\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UINT40`.\\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\\n uint256 xUint = UD60x18.unwrap(x);\\n if (xUint > MAX_UINT40) {\\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\\n }\\n result = uint40(xUint);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Alias for {wrap}.\\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\\n/// @notice Unwraps a UD60x18 number into uint256.\\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x);\\n}\\n\\n/// @notice Wraps a uint256 number into the UD60x18 value type.\\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\\n result = UD60x18.wrap(x);\\n}\\n\",\"keccak256\":\"0x5bb532da36921cbdac64d1f16de5d366ef1f664502e3b7c07d0ad06917551f85\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n// NOTICE: the \\\"u\\\" prefix stands for \\\"unwrapped\\\".\\n\\n/// @dev Euler's number as a UD60x18 number.\\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\\n\\n/// @dev The maximum input permitted in {exp}.\\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\\n\\n/// @dev The maximum input permitted in {exp2}.\\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\\n\\n/// @dev Half the UNIT number.\\nuint256 constant uHALF_UNIT = 0.5e18;\\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\\n\\n/// @dev $log_2(10)$ as a UD60x18 number.\\nuint256 constant uLOG2_10 = 3_321928094887362347;\\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\\n\\n/// @dev $log_2(e)$ as a UD60x18 number.\\nuint256 constant uLOG2_E = 1_442695040888963407;\\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\\n\\n/// @dev The maximum value a UD60x18 number can have.\\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\\n\\n/// @dev The maximum whole value a UD60x18 number can have.\\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\\n\\n/// @dev PI as a UD60x18 number.\\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\\n\\n/// @dev The unit number, which gives the decimal precision of UD60x18.\\nuint256 constant uUNIT = 1e18;\\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\\n\\n/// @dev The unit number squared.\\nuint256 constant uUNIT_SQUARED = 1e36;\\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\\n\\n/// @dev Zero as a UD60x18 number.\\nUD60x18 constant ZERO = UD60x18.wrap(0);\\n\",\"keccak256\":\"0x2b80d26153d3fdcfb3a9ca772d9309d31ed1275f5b8b54c3ffb54d3652b37d90\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Conversions.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { uMAX_UD60x18, uUNIT } from \\\"./Constants.sol\\\";\\nimport { PRBMath_UD60x18_Convert_Overflow } from \\\"./Errors.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\\n/// @dev The result is rounded toward zero.\\n/// @param x The UD60x18 number to convert.\\n/// @return result The same number in basic integer form.\\nfunction convert(UD60x18 x) pure returns (uint256 result) {\\n result = UD60x18.unwrap(x) / uUNIT;\\n}\\n\\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\\n///\\n/// @dev Requirements:\\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The basic integer to convert.\\n/// @param result The same number converted to UD60x18.\\nfunction convert(uint256 x) pure returns (UD60x18 result) {\\n if (x > uMAX_UD60x18 / uUNIT) {\\n revert PRBMath_UD60x18_Convert_Overflow(x);\\n }\\n unchecked {\\n result = UD60x18.wrap(x * uUNIT);\\n }\\n}\\n\",\"keccak256\":\"0xaf7fc2523413822de3b66ba339fe2884fb3b8c6f6cf38ec90a2c3e3aae71df6b\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Thrown when ceiling a number overflows UD60x18.\\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\\n\\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\\n\\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\\n\\n/// @notice Thrown when taking the logarithm of a number less than 1.\\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\\n\\n/// @notice Thrown when calculating the square root overflows UD60x18.\\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\\n\",\"keccak256\":\"0xa8c60d4066248df22c49c882873efbc017344107edabc48c52209abbc39cb1e3\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() + y.unwrap());\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & bits);\\n}\\n\\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() & y.unwrap());\\n}\\n\\n/// @notice Implements the equal operation (==) in the UD60x18 type.\\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() == y.unwrap();\\n}\\n\\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() > y.unwrap();\\n}\\n\\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() >= y.unwrap();\\n}\\n\\n/// @notice Implements a zero comparison check function in the UD60x18 type.\\nfunction isZero(UD60x18 x) pure returns (bool result) {\\n // This wouldn't work if x could be negative.\\n result = x.unwrap() == 0;\\n}\\n\\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() << bits);\\n}\\n\\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() < y.unwrap();\\n}\\n\\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() <= y.unwrap();\\n}\\n\\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() % y.unwrap());\\n}\\n\\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\\n result = x.unwrap() != y.unwrap();\\n}\\n\\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\\n result = wrap(~x.unwrap());\\n}\\n\\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() | y.unwrap());\\n}\\n\\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() >> bits);\\n}\\n\\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() - y.unwrap());\\n}\\n\\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() + y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(x.unwrap() - y.unwrap());\\n }\\n}\\n\\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(x.unwrap() ^ y.unwrap());\\n}\\n\",\"keccak256\":\"0xf5faff881391d2c060029499a666cc5f0bea90a213150bb476fae8f02a5df268\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"../Common.sol\\\" as Common;\\nimport \\\"./Errors.sol\\\" as Errors;\\nimport { wrap } from \\\"./Casting.sol\\\";\\nimport {\\n uEXP_MAX_INPUT,\\n uEXP2_MAX_INPUT,\\n uHALF_UNIT,\\n uLOG2_10,\\n uLOG2_E,\\n uMAX_UD60x18,\\n uMAX_WHOLE_UD60x18,\\n UNIT,\\n uUNIT,\\n uUNIT_SQUARED,\\n ZERO\\n} from \\\"./Constants.sol\\\";\\nimport { UD60x18 } from \\\"./ValueType.sol\\\";\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n/// @notice Calculates the arithmetic average of x and y using the following formula:\\n///\\n/// $$\\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\\n/// $$\\n///\\n/// In English, this is what this formula does:\\n///\\n/// 1. AND x and y.\\n/// 2. Calculate half of XOR x and y.\\n/// 3. Add the two results together.\\n///\\n/// This technique is known as SWAR, which stands for \\\"SIMD within a register\\\". You can read more about it here:\\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The arithmetic average as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n unchecked {\\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\\n }\\n}\\n\\n/// @notice Yields the smallest whole number greater than or equal to x.\\n///\\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n///\\n/// Requirements:\\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\\n///\\n/// @param x The UD60x18 number to ceil.\\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint > uMAX_WHOLE_UD60x18) {\\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\\n }\\n\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `UNIT - remainder`.\\n let delta := sub(uUNIT, remainder)\\n\\n // Equivalent to `x + remainder > 0 ? delta : 0`.\\n result := add(x, mul(delta, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @param x The numerator as a UD60x18 number.\\n/// @param y The denominator as a UD60x18 number.\\n/// @param result The quotient as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\\n}\\n\\n/// @notice Calculates the natural exponent of x using the following formula:\\n///\\n/// $$\\n/// e^x = 2^{x * log_2{e}}\\n/// $$\\n///\\n/// @dev Requirements:\\n/// - x must be less than 133_084258667509499441.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // This check prevents values greater than 192e18 from being passed to {exp2}.\\n if (xUint > uEXP_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\\n }\\n\\n unchecked {\\n // Inline the fixed-point multiplication to save gas.\\n uint256 doubleUnitProduct = xUint * uLOG2_E;\\n result = exp2(wrap(doubleUnitProduct / uUNIT));\\n }\\n}\\n\\n/// @notice Calculates the binary exponent of x using the binary fraction method.\\n///\\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\\n///\\n/// Requirements:\\n/// - x must be less than 192e18.\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\\n if (xUint > uEXP2_MAX_INPUT) {\\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\\n }\\n\\n // Convert x to the 192.64-bit fixed-point format.\\n uint256 x_192x64 = (xUint << 64) / uUNIT;\\n\\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\\n result = wrap(Common.exp2(x_192x64));\\n}\\n\\n/// @notice Yields the greatest whole number less than or equal to x.\\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\\n/// @param x The UD60x18 number to floor.\\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n // Equivalent to `x % UNIT`.\\n let remainder := mod(x, uUNIT)\\n\\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\\n result := sub(x, mul(remainder, gt(remainder, 0)))\\n }\\n}\\n\\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\\n/// @param x The UD60x18 number to get the fractional part of.\\n/// @param result The fractional part of x as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\\n assembly (\\\"memory-safe\\\") {\\n result := mod(x, uUNIT)\\n }\\n}\\n\\n/// @notice Calculates the geometric mean of x and y, i.e. $\\\\sqrt{x * y}$, rounding down.\\n///\\n/// @dev Requirements:\\n/// - x * y must fit in UD60x18.\\n///\\n/// @param x The first operand as a UD60x18 number.\\n/// @param y The second operand as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n if (xUint == 0 || yUint == 0) {\\n return ZERO;\\n }\\n\\n unchecked {\\n // Checking for overflow this way is faster than letting Solidity do it.\\n uint256 xyUint = xUint * yUint;\\n if (xyUint / xUint != yUint) {\\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\\n }\\n\\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\\n // during multiplication. See the comments in {Common.sqrt}.\\n result = wrap(Common.sqrt(xyUint));\\n }\\n}\\n\\n/// @notice Calculates the inverse of x.\\n///\\n/// @dev Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must not be zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the inverse.\\n/// @return result The inverse as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n result = wrap(uUNIT_SQUARED / x.unwrap());\\n }\\n}\\n\\n/// @notice Calculates the natural logarithm of x using the following formula:\\n///\\n/// $$\\n/// ln{x} = log_2{x} / log_2{e}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\\n/// @return result The natural logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\\n unchecked {\\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\\n // {log2} can return is ~196_205294292027477728.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\\n }\\n}\\n\\n/// @notice Calculates the common logarithm of x using the following formula:\\n///\\n/// $$\\n/// log_{10}{x} = log_2{x} / log_2{10}\\n/// $$\\n///\\n/// However, if x is an exact power of ten, a hard coded value is returned.\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {log2}.\\n///\\n/// @param x The UD60x18 number for which to calculate the common logarithm.\\n/// @return result The common logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\\n // prettier-ignore\\n assembly (\\\"memory-safe\\\") {\\n switch x\\n case 1 { result := mul(uUNIT, sub(0, 18)) }\\n case 10 { result := mul(uUNIT, sub(1, 18)) }\\n case 100 { result := mul(uUNIT, sub(2, 18)) }\\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\\n case 1000000000000000000 { result := 0 }\\n case 10000000000000000000 { result := uUNIT }\\n case 100000000000000000000 { result := mul(uUNIT, 2) }\\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\\n default { result := uMAX_UD60x18 }\\n }\\n\\n if (result.unwrap() == uMAX_UD60x18) {\\n unchecked {\\n // Inline the fixed-point division to save gas.\\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\\n }\\n }\\n}\\n\\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\\n///\\n/// $$\\n/// log_2{x} = n + log_2{y}, \\\\text{ where } y = x*2^{-n}, \\\\ y \\\\in [1, 2)\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, the input is inverted:\\n///\\n/// $$\\n/// log_2{x} = -log_2{\\\\frac{1}{x}}\\n/// $$\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\\n///\\n/// Notes:\\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\\n///\\n/// Requirements:\\n/// - x must be greater than zero.\\n///\\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\\n/// @return result The binary logarithm as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n if (xUint < uUNIT) {\\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\\n }\\n\\n unchecked {\\n // Calculate the integer part of the logarithm.\\n uint256 n = Common.msb(xUint / uUNIT);\\n\\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\\n // n is at most 255 and UNIT is 1e18.\\n uint256 resultUint = n * uUNIT;\\n\\n // Calculate $y = x * 2^{-n}$.\\n uint256 y = xUint >> n;\\n\\n // If y is the unit number, the fractional part is zero.\\n if (y == uUNIT) {\\n return wrap(resultUint);\\n }\\n\\n // Calculate the fractional part via the iterative approximation.\\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\\n uint256 DOUBLE_UNIT = 2e18;\\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\\n y = (y * y) / uUNIT;\\n\\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\\n if (y >= DOUBLE_UNIT) {\\n // Add the 2^{-m} factor to the logarithm.\\n resultUint += delta;\\n\\n // Halve y, which corresponds to z/2 in the Wikipedia article.\\n y >>= 1;\\n }\\n }\\n result = wrap(resultUint);\\n }\\n}\\n\\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\\n///\\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv}.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {Common.mulDiv}.\\n///\\n/// @dev See the documentation in {Common.mulDiv18}.\\n/// @param x The multiplicand as a UD60x18 number.\\n/// @param y The multiplier as a UD60x18 number.\\n/// @return result The product as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\\n}\\n\\n/// @notice Raises x to the power of y.\\n///\\n/// For $1 \\\\leq x \\\\leq \\\\infty$, the following standard formula is used:\\n///\\n/// $$\\n/// x^y = 2^{log_2{x} * y}\\n/// $$\\n///\\n/// For $0 \\\\leq x \\\\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\\n///\\n/// $$\\n/// i = \\\\frac{1}{x}\\n/// w = 2^{log_2{i} * y}\\n/// x^y = \\\\frac{1}{w}\\n/// $$\\n///\\n/// @dev Notes:\\n/// - Refer to the notes in {log2} and {mul}.\\n/// - Returns `UNIT` for 0^0.\\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\\n///\\n/// Requirements:\\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a UD60x18 number.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n uint256 yUint = y.unwrap();\\n\\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\\n if (xUint == 0) {\\n return yUint == 0 ? UNIT : ZERO;\\n }\\n // If x is `UNIT`, the result is always `UNIT`.\\n else if (xUint == uUNIT) {\\n return UNIT;\\n }\\n\\n // If y is zero, the result is always `UNIT`.\\n if (yUint == 0) {\\n return UNIT;\\n }\\n // If y is `UNIT`, the result is always x.\\n else if (yUint == uUNIT) {\\n return x;\\n }\\n\\n // If x is greater than `UNIT`, use the standard formula.\\n if (xUint > uUNIT) {\\n result = exp2(mul(log2(x), y));\\n }\\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\\n else {\\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\\n UD60x18 w = exp2(mul(log2(i), y));\\n result = wrap(uUNIT_SQUARED / w.unwrap());\\n }\\n}\\n\\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\\n/// algorithm \\\"exponentiation by squaring\\\".\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\\n///\\n/// Notes:\\n/// - Refer to the notes in {Common.mulDiv18}.\\n/// - Returns `UNIT` for 0^0.\\n///\\n/// Requirements:\\n/// - The result must fit in UD60x18.\\n///\\n/// @param x The base as a UD60x18 number.\\n/// @param y The exponent as a uint256.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\\n // Calculate the first iteration of the loop in advance.\\n uint256 xUint = x.unwrap();\\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\\n\\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\\n for (y >>= 1; y > 0; y >>= 1) {\\n xUint = Common.mulDiv18(xUint, xUint);\\n\\n // Equivalent to `y % 2 == 1`.\\n if (y & 1 > 0) {\\n resultUint = Common.mulDiv18(resultUint, xUint);\\n }\\n }\\n result = wrap(resultUint);\\n}\\n\\n/// @notice Calculates the square root of x using the Babylonian method.\\n///\\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\\n///\\n/// Notes:\\n/// - The result is rounded toward zero.\\n///\\n/// Requirements:\\n/// - x must be less than `MAX_UD60x18 / UNIT`.\\n///\\n/// @param x The UD60x18 number for which to calculate the square root.\\n/// @return result The result as a UD60x18 number.\\n/// @custom:smtchecker abstract-function-nondet\\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\\n uint256 xUint = x.unwrap();\\n\\n unchecked {\\n if (xUint > uMAX_UD60x18 / uUNIT) {\\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\\n }\\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\\n // In this case, the two numbers are both the square root.\\n result = wrap(Common.sqrt(xUint * uUNIT));\\n }\\n}\\n\",\"keccak256\":\"0x462144667aac3f96d5f8dba7aa68fe4c5a3f61e1d7bbbc81bee21168817f9c09\",\"license\":\"MIT\"},\"@prb/math/src/ud60x18/ValueType.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.19;\\n\\nimport \\\"./Casting.sol\\\" as Casting;\\nimport \\\"./Helpers.sol\\\" as Helpers;\\nimport \\\"./Math.sol\\\" as Math;\\n\\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\\n/// @dev The value type is defined here so it can be imported in all other files.\\ntype UD60x18 is uint256;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n CASTING\\n//////////////////////////////////////////////////////////////////////////*/\\n\\nusing {\\n Casting.intoSD1x18,\\n Casting.intoUD2x18,\\n Casting.intoSD59x18,\\n Casting.intoUint128,\\n Casting.intoUint256,\\n Casting.intoUint40,\\n Casting.unwrap\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n MATHEMATICAL FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Math.avg,\\n Math.ceil,\\n Math.div,\\n Math.exp,\\n Math.exp2,\\n Math.floor,\\n Math.frac,\\n Math.gm,\\n Math.inv,\\n Math.ln,\\n Math.log10,\\n Math.log2,\\n Math.mul,\\n Math.pow,\\n Math.powu,\\n Math.sqrt\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n HELPER FUNCTIONS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes the functions in this library callable on the UD60x18 type.\\nusing {\\n Helpers.add,\\n Helpers.and,\\n Helpers.eq,\\n Helpers.gt,\\n Helpers.gte,\\n Helpers.isZero,\\n Helpers.lshift,\\n Helpers.lt,\\n Helpers.lte,\\n Helpers.mod,\\n Helpers.neq,\\n Helpers.not,\\n Helpers.or,\\n Helpers.rshift,\\n Helpers.sub,\\n Helpers.uncheckedAdd,\\n Helpers.uncheckedSub,\\n Helpers.xor\\n} for UD60x18 global;\\n\\n/*//////////////////////////////////////////////////////////////////////////\\n OPERATORS\\n//////////////////////////////////////////////////////////////////////////*/\\n\\n// The global \\\"using for\\\" directive makes it possible to use these operators on the UD60x18 type.\\nusing {\\n Helpers.add as +,\\n Helpers.and2 as &,\\n Math.div as /,\\n Helpers.eq as ==,\\n Helpers.gt as >,\\n Helpers.gte as >=,\\n Helpers.lt as <,\\n Helpers.lte as <=,\\n Helpers.or as |,\\n Helpers.mod as %,\\n Math.mul as *,\\n Helpers.neq as !=,\\n Helpers.not as ~,\\n Helpers.sub as -,\\n Helpers.xor as ^\\n} for UD60x18 global;\\n\",\"keccak256\":\"0xdd873b5124180d9b71498b3a7fe93b1c08c368bec741f7d5f8e17f78a0b70f31\",\"license\":\"MIT\"},\"@sablier/v2-core/src/interfaces/IAdminable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.19;\\n\\n/// @title IAdminable\\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\\n/// in the constructor.\\ninterface IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin is transferred.\\n /// @param oldAdmin The address of the old admin.\\n /// @param newAdmin The address of the new admin.\\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice The address of the admin account or contract.\\n function admin() external view returns (address);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Transfers the contract admin to a new address.\\n ///\\n /// @dev Notes:\\n /// - Does not revert if the admin is the same.\\n /// - This function can potentially leave the contract without an admin, thereby removing any\\n /// functionality that is only available to the admin.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newAdmin The address of the new admin.\\n function transferAdmin(address newAdmin) external;\\n}\\n\",\"keccak256\":\"0xecc2d5f08b737e1acd5f641de59b262831c520adf8cd7290d02efe39e0ae443e\",\"license\":\"GPL-3.0-or-later\"},\"@sablier/v2-core/src/interfaces/ISablierV2Base.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.19;\\n\\nimport { IERC20 } from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport { UD60x18 } from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\nimport { IAdminable } from \\\"./IAdminable.sol\\\";\\nimport { ISablierV2Comptroller } from \\\"./ISablierV2Comptroller.sol\\\";\\n\\n/// @title ISablierV2Base\\n/// @notice Base logic for all Sablier V2 streaming contracts.\\ninterface ISablierV2Base is IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin claims all protocol revenues accrued for a particular ERC-20 asset.\\n /// @param admin The address of the contract admin.\\n /// @param asset The contract address of the ERC-20 asset the protocol revenues have been claimed for.\\n /// @param protocolRevenues The amount of protocol revenues claimed, denoted in units of the asset's decimals.\\n event ClaimProtocolRevenues(address indexed admin, IERC20 indexed asset, uint128 protocolRevenues);\\n\\n /// @notice Emitted when the admin sets a new comptroller contract.\\n /// @param admin The address of the contract admin.\\n /// @param oldComptroller The address of the old comptroller contract.\\n /// @param newComptroller The address of the new comptroller contract.\\n event SetComptroller(\\n address indexed admin, ISablierV2Comptroller oldComptroller, ISablierV2Comptroller newComptroller\\n );\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the maximum fee that can be charged by the protocol or a broker, denoted as a fixed-point\\n /// number where 1e18 is 100%.\\n /// @dev This value is hard coded as a constant.\\n function MAX_FEE() external view returns (UD60x18);\\n\\n /// @notice Retrieves the address of the comptroller contract, responsible for the Sablier V2 protocol\\n /// configuration.\\n function comptroller() external view returns (ISablierV2Comptroller);\\n\\n /// @notice Retrieves the protocol revenues accrued for the provided ERC-20 asset, in units of the asset's\\n /// decimals.\\n /// @param asset The contract address of the ERC-20 asset to query.\\n function protocolRevenues(IERC20 asset) external view returns (uint128 revenues);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Claims all accumulated protocol revenues for the provided ERC-20 asset.\\n ///\\n /// @dev Emits a {ClaimProtocolRevenues} event.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param asset The contract address of the ERC-20 asset for which to claim protocol revenues.\\n function claimProtocolRevenues(IERC20 asset) external;\\n\\n /// @notice Assigns a new comptroller contract responsible for the protocol configuration.\\n ///\\n /// @dev Emits a {SetComptroller} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the comptroller is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newComptroller The address of the new comptroller contract.\\n function setComptroller(ISablierV2Comptroller newComptroller) external;\\n}\\n\",\"keccak256\":\"0xb12e58a05389c958f79ebe1667e167c1e0bb681a18ae534f5e454abbd66f6821\",\"license\":\"GPL-3.0-or-later\"},\"@sablier/v2-core/src/interfaces/ISablierV2Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.19;\\n\\nimport { IERC20 } from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport { UD60x18 } from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\nimport { IAdminable } from \\\"./IAdminable.sol\\\";\\n\\n/// @title ISablierV2Controller\\n/// @notice This contract is in charge of the Sablier V2 protocol configuration, handling such values as the\\n/// protocol fees.\\ninterface ISablierV2Comptroller is IAdminable {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when the admin sets a new flash fee.\\n /// @param admin The address of the contract admin.\\n /// @param oldFlashFee The old flash fee, denoted as a fixed-point number.\\n /// @param newFlashFee The new flash fee, denoted as a fixed-point number.\\n event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);\\n\\n /// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.\\n /// @param admin The address of the contract admin.\\n /// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.\\n /// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.\\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.\\n event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);\\n\\n /// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.\\n /// @param admin The address of the contract admin.\\n /// @param asset The contract address of the ERC-20 asset to toggle.\\n /// @param newFlag Whether the ERC-20 asset can be flash loaned.\\n event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.\\n ///\\n /// @dev Notes:\\n /// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},\\n /// which calculates the fee amount for a specified flash loan amount.\\n /// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.\\n function flashFee() external view returns (UD60x18 fee);\\n\\n /// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.\\n /// @param token The contract address of the ERC-20 asset to check.\\n function isFlashAsset(IERC20 token) external view returns (bool result);\\n\\n /// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.\\n /// @param asset The contract address of the ERC-20 asset to query.\\n /// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.\\n function protocolFees(IERC20 asset) external view returns (UD60x18 fee);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.\\n ///\\n /// @dev Emits a {SetFlashFee} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the fee is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.\\n function setFlashFee(UD60x18 newFlashFee) external;\\n\\n /// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.\\n ///\\n /// @dev Emits a {SetProtocolFee} event.\\n ///\\n /// Notes:\\n /// - The fee is not denoted in units of the asset's decimals; it is a fixed-point number. Refer to the\\n /// PRBMath documentation for more detail on the logic of UD60x18.\\n /// - Does not revert if the fee is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param asset The contract address of the ERC-20 asset to update the fee for.\\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.\\n function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;\\n\\n /// @notice Toggles the flash loanability of an ERC-20 asset.\\n ///\\n /// @dev Emits a {ToggleFlashAsset} event.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the admin.\\n ///\\n /// @param asset The address of the ERC-20 asset to toggle.\\n function toggleFlashAsset(IERC20 asset) external;\\n}\\n\",\"keccak256\":\"0xfe089975be90f0efeeafc9ac9dfa5c301ca1f5c178177ac5589a8483a0aa84a3\",\"license\":\"GPL-3.0-or-later\"},\"@sablier/v2-core/src/interfaces/ISablierV2Lockup.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.19;\\n\\nimport { IERC20 } from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport { IERC721Metadata } from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\n\\nimport { Lockup } from \\\"../types/DataTypes.sol\\\";\\nimport { ISablierV2Base } from \\\"./ISablierV2Base.sol\\\";\\nimport { ISablierV2NFTDescriptor } from \\\"./ISablierV2NFTDescriptor.sol\\\";\\n\\n/// @title ISablierV2Lockup\\n/// @notice Common logic between all Sablier V2 Lockup streaming contracts.\\ninterface ISablierV2Lockup is\\n ISablierV2Base, // 1 inherited component\\n IERC721Metadata // 2 inherited components\\n{\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when a stream is canceled.\\n /// @param streamId The id of the stream.\\n /// @param sender The address of the stream's sender.\\n /// @param recipient The address of the stream's recipient.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\\n /// decimals.\\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\\n /// asset's decimals.\\n event CancelLockupStream(\\n uint256 streamId,\\n address indexed sender,\\n address indexed recipient,\\n IERC20 indexed asset,\\n uint128 senderAmount,\\n uint128 recipientAmount\\n );\\n\\n /// @notice Emitted when a sender gives up the right to cancel a stream.\\n /// @param streamId The id of the stream.\\n event RenounceLockupStream(uint256 indexed streamId);\\n\\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\\n /// @param admin The address of the current contract admin.\\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n event SetNFTDescriptor(\\n address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor\\n );\\n\\n /// @notice Emitted when assets are withdrawn from a stream.\\n /// @param streamId The id of the stream.\\n /// @param to The address that has received the withdrawn assets.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\\n event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the address of the ERC-20 asset used for streaming.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\\n\\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);\\n\\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getEndTime(uint256 streamId) external view returns (uint40 endTime);\\n\\n /// @notice Retrieves the stream's recipient.\\n /// @dev Reverts if the NFT has been burned.\\n /// @param streamId The stream id for the query.\\n function getRecipient(uint256 streamId) external view returns (address recipient);\\n\\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\\n /// decimals. This amount is always zero unless the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);\\n\\n /// @notice Retrieves the stream's sender.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getSender(uint256 streamId) external view returns (address sender);\\n\\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getStartTime(uint256 streamId) external view returns (uint40 startTime);\\n\\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);\\n\\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\\n /// flag is always `false`.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function isCancelable(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function isCold(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is depleted.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function isDepleted(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream exists.\\n /// @dev Does not revert if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function isStream(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function isTransferable(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function isWarm(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Counter for stream ids, used in the create functions.\\n function nextStreamId() external view returns (uint256);\\n\\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\\n /// of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);\\n\\n /// @notice Retrieves the stream's status.\\n /// @param streamId The stream id for the query.\\n function statusOf(uint256 streamId) external view returns (Lockup.Status status);\\n\\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\\n\\n /// @notice Retrieves a flag indicating whether the stream was canceled.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function wasCanceled(uint256 streamId) external view returns (bool result);\\n\\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\\n /// decimals.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Burns the NFT associated with the stream.\\n ///\\n /// @dev Emits a {Transfer} event.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a depleted stream.\\n /// - The NFT must exist.\\n /// - `msg.sender` must be either the NFT owner or an approved third party.\\n ///\\n /// @param streamId The id of the stream NFT to burn.\\n function burn(uint256 streamId) external;\\n\\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\\n /// stream is marked as depleted.\\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - The stream must be warm and cancelable.\\n /// - `msg.sender` must be the stream's sender.\\n ///\\n /// @param streamId The id of the stream to cancel.\\n function cancel(uint256 streamId) external;\\n\\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\\n ///\\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {cancel}.\\n ///\\n /// Requirements:\\n /// - All requirements from {cancel} must be met for each stream.\\n ///\\n /// @param streamIds The ids of the streams to cancel.\\n function cancelMultiple(uint256[] calldata streamIds) external;\\n\\n /// @notice Removes the right of the stream's sender to cancel the stream.\\n ///\\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This is an irreversible operation.\\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must reference a warm stream.\\n /// - `msg.sender` must be the stream's sender.\\n /// - The stream must be cancelable.\\n ///\\n /// @param streamId The id of the stream to renounce.\\n function renounce(uint256 streamId) external;\\n\\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\\n ///\\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Does not revert if the NFT descriptor is the same.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the contract admin.\\n ///\\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\\n function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;\\n\\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract\\n /// and `msg.sender` is either the sender or an approved operator.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `streamId` must not reference a null or depleted stream.\\n /// - `msg.sender` must be the stream's sender, the stream's recipient or an approved third party.\\n /// - `to` must be the recipient if `msg.sender` is the stream's sender.\\n /// - `to` must not be the zero address.\\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\\n ///\\n /// @param streamId The id of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\\n function withdraw(uint256 streamId, address to, uint128 amount) external;\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\\n ///\\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\\n ///\\n /// Notes:\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - Refer to the requirements in {withdraw}.\\n ///\\n /// @param streamId The id of the stream to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n function withdrawMax(uint256 streamId, address to) external;\\n\\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\\n /// NFT to `newRecipient`.\\n ///\\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\\n ///\\n /// Notes:\\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\\n /// - Refer to the notes in {withdraw}.\\n ///\\n /// Requirements:\\n /// - `msg.sender` must be the stream's recipient.\\n /// - Refer to the requirements in {withdraw}.\\n /// - Refer to the requirements in {IERC721.transferFrom}.\\n ///\\n /// @param streamId The id of the stream NFT to transfer.\\n /// @param newRecipient The address of the new owner of the stream NFT.\\n function withdrawMaxAndTransfer(uint256 streamId, address newRecipient) external;\\n\\n /// @notice Withdraws assets from streams to the provided address `to`.\\n ///\\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\\n ///\\n /// Notes:\\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\\n ///\\n /// Requirements:\\n /// - All requirements from {withdraw} must be met for each stream.\\n /// - There must be an equal number of `streamIds` and `amounts`.\\n ///\\n /// @param streamIds The ids of the streams to withdraw from.\\n /// @param to The address receiving the withdrawn assets.\\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\\n function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;\\n}\\n\",\"keccak256\":\"0x61abd439ba9729781bb32bc6b267cbfdbdf66177e40ce449399054ffd57cdbea\",\"license\":\"GPL-3.0-or-later\"},\"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.19;\\n\\nimport { IERC20 } from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\nimport { Lockup, LockupLinear } from \\\"../types/DataTypes.sol\\\";\\nimport { ISablierV2Lockup } from \\\"./ISablierV2Lockup.sol\\\";\\n\\n/// @title ISablierV2LockupLinear\\n/// @notice Creates and manages Lockup streams with linear streaming functions.\\ninterface ISablierV2LockupLinear is ISablierV2Lockup {\\n /*//////////////////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Emitted when a stream is created.\\n /// @param streamId The id of the newly created stream.\\n /// @param funder The address which funded the stream.\\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\\n /// @param recipient The address receiving the assets.\\n /// @param amounts Struct containing (i) the deposit amount, (ii) the protocol fee amount, and (iii) the\\n /// broker fee amount, all denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param cancelable Boolean indicating whether the stream will be cancelable or not.\\n /// @param transferable Boolean indicating whether the stream NFT is transferable or not.\\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\\n /// timestamps.\\n /// @param broker The address of the broker who has helped create the stream, e.g. a front-end website.\\n event CreateLockupLinearStream(\\n uint256 streamId,\\n address funder,\\n address indexed sender,\\n address indexed recipient,\\n Lockup.CreateAmounts amounts,\\n IERC20 indexed asset,\\n bool cancelable,\\n bool transferable,\\n LockupLinear.Range range,\\n address broker\\n );\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Retrieves the stream's cliff time, which is a Unix timestamp.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);\\n\\n /// @notice Retrieves the stream's range, which is a struct containing (i) the stream's start time, (ii) cliff\\n /// time, and (iii) end time, all as Unix timestamps.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);\\n\\n /// @notice Retrieves the stream entity.\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);\\n\\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\\n ///\\n /// When the stream is warm, the streaming function is:\\n ///\\n /// $$\\n /// f(x) = x * d + c\\n /// $$\\n ///\\n /// Where:\\n ///\\n /// - $x$ is the elapsed time divided by the stream's total duration.\\n /// - $d$ is the deposited amount.\\n /// - $c$ is the cliff amount.\\n ///\\n /// Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\\n /// to the total amount withdrawn.\\n ///\\n /// @dev Reverts if `streamId` references a null stream.\\n /// @param streamId The stream id for the query.\\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\\n\\n /*//////////////////////////////////////////////////////////////////////////\\n NON-CONSTANT FUNCTIONS\\n //////////////////////////////////////////////////////////////////////////*/\\n\\n /// @notice Creates a stream by setting the start time to `block.timestamp`, and the end time to\\n /// the sum of `block.timestamp` and `params.durations.total`. The stream is funded by `msg.sender` and is wrapped\\n /// in an ERC-721 NFT.\\n ///\\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\\n ///\\n /// Requirements:\\n /// - All requirements in {createWithRange} must be met for the calculated parameters.\\n ///\\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\\n /// @return streamId The id of the newly created stream.\\n function createWithDurations(LockupLinear.CreateWithDurations calldata params)\\n external\\n returns (uint256 streamId);\\n\\n /// @notice Creates a stream with the provided start time and end time as the range. The stream is\\n /// funded by `msg.sender` and is wrapped in an ERC-721 NFT.\\n ///\\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\\n ///\\n /// Notes:\\n /// - As long as the times are ordered, it is not an error for the start or the cliff time to be in the past.\\n ///\\n /// Requirements:\\n /// - Must not be delegate called.\\n /// - `params.totalAmount` must be greater than zero.\\n /// - If set, `params.broker.fee` must not be greater than `MAX_FEE`.\\n /// - `params.range.start` must be less than or equal to `params.range.cliff`.\\n /// - `params.range.cliff` must be less than `params.range.end`.\\n /// - `params.range.end` must be in the future.\\n /// - `params.recipient` must not be the zero address.\\n /// - `msg.sender` must have allowed this contract to spend at least `params.totalAmount` assets.\\n ///\\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\\n /// @return streamId The id of the newly created stream.\\n function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);\\n}\\n\",\"keccak256\":\"0x9bbd77ed1d6c83e0f74cf4d6d77692e7ff85b2729df6cdba9daa68a1be1ea5dd\",\"license\":\"GPL-3.0-or-later\"},\"@sablier/v2-core/src/interfaces/ISablierV2NFTDescriptor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.19;\\n\\nimport { IERC721Metadata } from \\\"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\\\";\\n\\n/// @title ISablierV2NFTDescriptor\\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\\n/// @dev Inspired by Uniswap V3 Positions NFTs.\\ninterface ISablierV2NFTDescriptor {\\n /// @notice Produces the URI describing a particular stream NFT.\\n /// @dev This is a data URI with the JSON contents directly inlined.\\n /// @param sablier The address of the Sablier contract the stream was created in.\\n /// @param streamId The id of the stream for which to produce a description.\\n /// @return uri The URI of the ERC721-compliant metadata.\\n function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);\\n}\\n\",\"keccak256\":\"0x35172718298221f3aac87424252e4eaf7480ce901fe9a7b92d8fdd871ecdad3a\",\"license\":\"GPL-3.0-or-later\"},\"@sablier/v2-core/src/types/DataTypes.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity >=0.8.19;\\n\\nimport { IERC20 } from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport { UD2x18 } from \\\"@prb/math/src/UD2x18.sol\\\";\\nimport { UD60x18 } from \\\"@prb/math/src/UD60x18.sol\\\";\\n\\n// DataTypes.sol\\n//\\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\\n//\\n// - Lockup\\n// - LockupDynamic\\n// - LockupLinear\\n//\\n// You will notice that some structs contain \\\"slot\\\" annotations - they are used to indicate the\\n// storage layout of the struct. It is more gas efficient to group small data types together so\\n// that they fit in a single 32-byte slot.\\n\\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\\n/// @param account The address receiving the broker's fee.\\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\\nstruct Broker {\\n address account;\\n UD60x18 fee;\\n}\\n\\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\\nlibrary Lockup {\\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units\\n /// of the asset's decimals.\\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in\\n /// the same slot saves gas.\\n /// @param deposited The initial amount deposited in the stream, net of fees.\\n /// @param withdrawn The cumulative amount withdrawn from the stream.\\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\\n struct Amounts {\\n // slot 0\\n uint128 deposited;\\n uint128 withdrawn;\\n // slot 1\\n uint128 refunded;\\n }\\n\\n /// @notice Struct encapsulating the deposit amount, the protocol fee amount, and the broker fee amount,\\n /// all denoted in units of the asset's decimals.\\n /// @param deposit The amount to deposit in the stream.\\n /// @param protocolFee The protocol fee amount.\\n /// @param brokerFee The broker fee amount.\\n struct CreateAmounts {\\n uint128 deposit;\\n uint128 protocolFee;\\n uint128 brokerFee;\\n }\\n\\n /// @notice Enum representing the different statuses of a stream.\\n /// @custom:value PENDING Stream created but not started; assets are in a pending state.\\n /// @custom:value STREAMING Active stream where assets are currently being streamed.\\n /// @custom:value SETTLED All assets have been streamed; recipient is due to withdraw them.\\n /// @custom:value CANCELED Canceled stream; remaining assets await recipient's withdrawal.\\n /// @custom:value DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\\n enum Status {\\n PENDING, // value 0\\n STREAMING, // value 1\\n SETTLED, // value 2\\n CANCELED, // value 3\\n DEPLETED // value 4\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\\nlibrary LockupDynamic {\\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithDeltas} function.\\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\\n /// same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\\n /// fees, all denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n /// @param segments Segments with deltas used to compose the custom streaming curve. Milestones are calculated by\\n /// starting from `block.timestamp` and adding each delta to the previous milestone.\\n struct CreateWithDeltas {\\n address sender;\\n bool cancelable;\\n bool transferable;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n Broker broker;\\n SegmentWithDelta[] segments;\\n }\\n\\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithMilestones}\\n /// function.\\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\\n /// same as `msg.sender`.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\\n /// fees, all denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n /// @param segments Segments used to compose the custom streaming curve.\\n struct CreateWithMilestones {\\n address sender;\\n uint40 startTime;\\n bool cancelable;\\n bool transferable;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n Broker broker;\\n Segment[] segments;\\n }\\n\\n /// @notice Struct encapsulating the time range.\\n /// @param start The Unix timestamp indicating the stream's start.\\n /// @param end The Unix timestamp indicating the stream's end.\\n struct Range {\\n uint40 start;\\n uint40 end;\\n }\\n\\n /// @notice Segment struct used in the Lockup Dynamic stream.\\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\\n /// @param milestone The Unix timestamp indicating this segment's end.\\n struct Segment {\\n // slot 0\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 milestone;\\n }\\n\\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDeltas}.\\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\\n /// @param delta The time difference in seconds between this segment and the previous one.\\n struct SegmentWithDelta {\\n uint128 amount;\\n UD2x18 exponent;\\n uint40 delta;\\n }\\n\\n /// @notice Lockup Dynamic stream.\\n /// @dev The fields are arranged like this to save gas via tight variable packing.\\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param endTime The Unix timestamp indicating the stream's end.\\n /// @param isCancelable Boolean indicating if the stream is cancelable.\\n /// @param wasCanceled Boolean indicating if the stream was canceled.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param isDepleted Boolean indicating if the stream is depleted.\\n /// @param isStream Boolean indicating if the struct entity exists.\\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\\n /// asset's decimals.\\n /// @param segments Segments used to compose the custom streaming curve.\\n struct Stream {\\n // slot 0\\n address sender;\\n uint40 startTime;\\n uint40 endTime;\\n bool isCancelable;\\n bool wasCanceled;\\n // slot 1\\n IERC20 asset;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n // slot 2 and 3\\n Lockup.Amounts amounts;\\n // slots [4..n]\\n Segment[] segments;\\n }\\n}\\n\\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\\nlibrary LockupLinear {\\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithDurations} function.\\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\\n /// same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\\n /// fees, all denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds.\\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithDurations {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Durations durations;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithRange} function.\\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\\n /// same as `msg.sender`.\\n /// @param recipient The address receiving the assets.\\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\\n /// fees, all denoted in units of the asset's decimals.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param cancelable Indicates if the stream is cancelable.\\n /// @param transferable Indicates if the stream NFT is transferable.\\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\\n /// timestamps.\\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\\n struct CreateWithRange {\\n address sender;\\n address recipient;\\n uint128 totalAmount;\\n IERC20 asset;\\n bool cancelable;\\n bool transferable;\\n Range range;\\n Broker broker;\\n }\\n\\n /// @notice Struct encapsulating the cliff duration and the total duration.\\n /// @param cliff The cliff duration in seconds.\\n /// @param total The total duration in seconds.\\n struct Durations {\\n uint40 cliff;\\n uint40 total;\\n }\\n\\n /// @notice Struct encapsulating the time range.\\n /// @param start The Unix timestamp for the stream's start.\\n /// @param cliff The Unix timestamp for the cliff period's end.\\n /// @param end The Unix timestamp for the stream's end.\\n struct Range {\\n uint40 start;\\n uint40 cliff;\\n uint40 end;\\n }\\n\\n /// @notice Lockup Linear stream.\\n /// @dev The fields are arranged like this to save gas via tight variable packing.\\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\\n /// @param startTime The Unix timestamp indicating the stream's start.\\n /// @param cliffTime The Unix timestamp indicating the cliff period's end.\\n /// @param isCancelable Boolean indicating if the stream is cancelable.\\n /// @param wasCanceled Boolean indicating if the stream was canceled.\\n /// @param asset The contract address of the ERC-20 asset used for streaming.\\n /// @param endTime The Unix timestamp indicating the stream's end.\\n /// @param isDepleted Boolean indicating if the stream is depleted.\\n /// @param isStream Boolean indicating if the struct entity exists.\\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\\n /// asset's decimals.\\n struct Stream {\\n // slot 0\\n address sender;\\n uint40 startTime;\\n uint40 cliffTime;\\n bool isCancelable;\\n bool wasCanceled;\\n // slot 1\\n IERC20 asset;\\n uint40 endTime;\\n bool isDepleted;\\n bool isStream;\\n bool isTransferable;\\n // slot 2 and 3\\n Lockup.Amounts amounts;\\n }\\n}\\n\",\"keccak256\":\"0xe9f7db9149a892c339d0c72c26c322fe0f336061559bcd5fe761ed4add85b87f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/Token.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\nimport {ERC20} from \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport {ERC20Permit} from \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\\\";\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport {IStratosphere} from \\\"./interfaces/IStratosphere.sol\\\";\\n\\nerror Token__MissingLiquidityPool();\\nerror Token__ExceedsMaximumHolding();\\nerror Token__TradingNotStarted();\\nerror Token__NonStratosphereNFTHolder();\\nerror Token__BotDetected();\\n\\ncontract Token is ERC20, ERC20Permit, Ownable {\\n address public liquidityPool;\\n address public immutable dexAggregator;\\n address public immutable dexAdapter;\\n uint256 public immutable maxHoldingAmount;\\n uint256 public immutable tradingStartsAt;\\n IStratosphere public immutable stratosphere;\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint256 _supply,\\n address _stratosphereAddress,\\n address _owner,\\n uint256 _tradingStartsAt,\\n address _dexAggregator,\\n address _dexAdapter\\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\\n stratosphere = IStratosphere(_stratosphereAddress);\\n _mint(msg.sender, _supply);\\n maxHoldingAmount = _percentage(_supply, 100); // 1% of total supply\\n tradingStartsAt = _tradingStartsAt;\\n dexAggregator = _dexAggregator;\\n dexAdapter = _dexAdapter;\\n }\\n\\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\\n if (_liquidityPool == address(0)) {\\n revert Token__MissingLiquidityPool();\\n }\\n liquidityPool = _liquidityPool;\\n }\\n\\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\\n function _update(\\n address from,\\n address to,\\n uint256 value\\n ) internal virtual override {\\n super._update(from, to, value);\\n uint256 _tradingStartsAt = tradingStartsAt;\\n\\n if (liquidityPool == address(0)) {\\n require(\\n from == owner() || to == owner(),\\n \\\"Patience - Trading Not Started Yet!\\\"\\n );\\n return;\\n }\\n\\n if (block.timestamp < _tradingStartsAt) {\\n revert Token__TradingNotStarted();\\n }\\n\\n uint256 _secondsSinceTradingStarted = block.timestamp -\\n _tradingStartsAt;\\n\\n if (_secondsSinceTradingStarted > 24 hours) {\\n return;\\n }\\n\\n if (_secondsSinceTradingStarted < 1 hours) {\\n _enforceAntiWhale(to, value);\\n if (!(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to))) {\\n revert Token__NonStratosphereNFTHolder();\\n }\\n } else if (_secondsSinceTradingStarted < 24 hours) {\\n _enforceAntiWhale(to, value);\\n }\\n }\\n\\n function _enforceAntiWhale(address to, uint256 value) internal view {\\n if (to != liquidityPool) {\\n uint256 newBalance = balanceOf(to) + value;\\n if (newBalance > maxHoldingAmount) {\\n revert Token__ExceedsMaximumHolding();\\n }\\n }\\n }\\n\\n function _isStratosphereMemberOrAdmin(address _address) internal view returns (bool pass) {\\n if (_address == dexAggregator || _address == dexAdapter || stratosphere.tokenIdOf(_address) != 0 ||\\n _address == liquidityPool) {\\n pass = true;\\n }\\n }\\n\\n function _percentage(\\n uint256 _number,\\n uint256 _percentageBasisPoints // Example: 1% is 100\\n ) internal pure returns (uint256) {\\n return (_number * _percentageBasisPoints) / 10_000;\\n }\\n}\\n\",\"keccak256\":\"0xa57e9d0b47a8a1f80c3b77eefc66b7a0f1210011082f4f23061f694e8115e3a5\",\"license\":\"MIT\"},\"contracts/TokenFactory.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {IVaporDEXFactory} from \\\"./interfaces/IVaporDEXFactory.sol\\\";\\nimport {IVaporDEXRouter} from \\\"./interfaces/IVaporDEXRouter.sol\\\";\\nimport {Token} from \\\"./Token.sol\\\";\\nimport {ISablierV2LockupLinear} from \\\"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\\\";\\nimport {LockupLinear} from \\\"@sablier/v2-core/src/types/DataTypes.sol\\\";\\nimport {IDexAggregator} from \\\"./interfaces/IDexAggregator.sol\\\";\\nimport {INonfungiblePositionManager} from \\\"./interfaces/INonfungiblePositionManager.sol\\\";\\n\\nerror TokenFactory__WrongConstructorArguments();\\nerror TokenFactory__LiquidityLockedOrDepleted();\\nerror TokenFactory__Unauthorized();\\nerror TokenFactory__ZeroAddress();\\nerror TokenFactory__WrongLaunchArguments();\\nerror TokenFactory__InsufficientBalance();\\nerror TokenFactory__Invalid();\\nerror TokenFactory__TranferFailed(address);\\nerror TokenFactory__NotEnoughLiquidity();\\nerror TokenFactory__MinimumLockDuration();\\n\\n/// @title TokenFactory\\n/// @author Roy & Jose\\n/// @notice This contract is used to launch new tokens and create liquidity for them\\n/// @dev Utilizes 'Sablier' for liquidity locking\\n\\ncontract TokenFactory is Ownable {\\n //////////////\\n /// EVENTS ///\\n //////////////\\n\\n event TokenLaunched(\\n address indexed _tokenAddress,\\n address indexed _creatorAddress,\\n uint256 indexed _tokenId\\n );\\n\\n event StreamCreated(\\n uint256 indexed _streamId,\\n address indexed _sender,\\n address indexed _pair\\n );\\n event LiquidityBurned(\\n address indexed pair,\\n address indexed _burner,\\n uint256 _amount\\n );\\n event LiquidityTokensUnlocked(\\n address indexed _pairAddress,\\n address indexed _receiver\\n );\\n event LiquidityTransferred(\\n address indexed _pairAddress,\\n address indexed _to\\n );\\n event LaunchFeeUpdated(uint256 _newFee);\\n event SlippageUpdated(uint256 _newSlippage);\\n event MinimumLiquidityETHUpdated(uint256 _newFee);\\n event MinimumLockDurationUpdated(uint40 _newFee);\\n event VaporDEXAdapterUpdated(address _newAdapter);\\n event EmergencyWithdraw(\\n address indexed _token,\\n uint256 indexed _amount,\\n address indexed _to\\n );\\n\\n ///////////////\\n /// STORAGE ///\\n ///////////////\\n address private immutable factory;\\n address private immutable router;\\n address private immutable stratosphere;\\n IDexAggregator private immutable vaporDexAggregator;\\n INonfungiblePositionManager private immutable nonFungiblePositionManager;\\n IERC20 private immutable WETH;\\n IERC20 private immutable USDC;\\n IERC20 private immutable VAPE;\\n address private vaporDexAdapter;\\n address private teamMultisig;\\n uint256 private launchFee;\\n uint256 public minLiquidityETH;\\n uint256 public slippage;\\n uint40 public minLockDuration;\\n uint256 public tokenCounter;\\n\\n mapping(address => uint256[]) private addressToCounters;\\n mapping(uint256 => address) private counterToAddress;\\n\\n // Sablier\\n ISablierV2LockupLinear private immutable sablier;\\n // Mapping to store the streamId for each pair and lp owner\\n mapping(address => mapping(address => uint256)) private liquidityLocks;\\n\\n /**\\n * @dev TokenFactory constructor initializes the contract with required parameters.\\n * @param owner Address of the contract owner.\\n * @param routerAddress Address of the VaporDEXRouter contract.\\n * @param stratosphereAddress Address of the Stratosphere contract.\\n * @param vaporDexAggregator Address of the VaporDEX aggregator.\\n * @param vaporDexAdapter Address of the VaporDEX adapter.\\n * @param usdc Address of the USDC token.\\n * @param vape Address of the VAPE token.\\n * @param launchFee Launch fee in USDC.\\n * @param uint256 minLiquidityETH;\\n * @param uint40 minLockDuration;\\n * @param sablier Address of the Sablier contract.\\n * @param nonFungiblePositionManager Uni v3 NFT Position Manager\\n * @param teamMultisig Multisig address\\n * @param slippage\\n */\\n struct DeployArgs {\\n address owner;\\n address routerAddress;\\n address stratosphereAddress;\\n address vaporDexAggregator;\\n address vaporDexAdapter;\\n address usdc;\\n address vape;\\n uint256 launchFee;\\n uint256 minLiquidityETH;\\n uint40 minLockDuration;\\n address sablier;\\n address nonFungiblePositionManager;\\n address teamMultisig;\\n uint256 slippage;\\n }\\n\\n /////////////////////////\\n ////// CONSTRUCTOR /////\\n ////////////////////////\\n\\n constructor(DeployArgs memory args) Ownable(args.owner) {\\n // Check for valid constructor arguments\\n if (\\n args.owner == address(0) ||\\n args.routerAddress == address(0) ||\\n args.stratosphereAddress == address(0) ||\\n args.vaporDexAggregator == address(0) ||\\n args.vaporDexAdapter == address(0) ||\\n args.usdc == address(0) ||\\n args.launchFee == 0 ||\\n args.sablier == address(0) ||\\n args.minLiquidityETH == 0 ||\\n args.minLockDuration == 0\\n ) {\\n revert TokenFactory__WrongConstructorArguments();\\n }\\n\\n // Initialize variables\\n slippage = args.slippage;\\n router = args.routerAddress;\\n IVaporDEXRouter _router = IVaporDEXRouter(args.routerAddress);\\n factory = _router.factory();\\n WETH = IERC20(_router.WETH());\\n USDC = IERC20(args.usdc);\\n VAPE = IERC20(args.vape);\\n minLiquidityETH = args.minLiquidityETH;\\n minLockDuration = args.minLockDuration;\\n\\n stratosphere = args.stratosphereAddress;\\n vaporDexAggregator = IDexAggregator(args.vaporDexAggregator);\\n vaporDexAdapter = args.vaporDexAdapter;\\n launchFee = args.launchFee;\\n sablier = ISablierV2LockupLinear(args.sablier);\\n nonFungiblePositionManager = INonfungiblePositionManager(\\n args.nonFungiblePositionManager\\n );\\n teamMultisig = args.teamMultisig;\\n }\\n\\n /**\\n * @dev Launches a new token with specified parameters.\\n * @param _name Name of the token.\\n * @param _symbol Symbol of the token.\\n * @param _totalSupply Total supply of the token.\\n * @param _tradingStartsAt Timestamp when trading starts for the token.\\n * @param lockDuration Number of days to lock liquidity for.\\n * @param _burnLiquidity Flag indicating whether to burn liquidity or lock it.\\n * @return _pair Address of the created token pair.\\n * @return _tokenAddress Address of the launched token.\\n * @return streamId Stream ID if liquidity is locked, otherwise 0.\\n */\\n\\n function launch(\\n string memory _name,\\n string memory _symbol,\\n uint256 _totalSupply,\\n uint256 _tradingStartsAt,\\n uint40 lockDuration,\\n bool _burnLiquidity\\n )\\n external\\n payable\\n returns (address _pair, address _tokenAddress, uint256 streamId)\\n {\\n if (msg.value < minLiquidityETH) {\\n revert TokenFactory__NotEnoughLiquidity();\\n }\\n // Step 0: Transfer Fee\\n _transferLaunchFee(msg.sender);\\n\\n // Step 1: Create the token\\n Token _token = _createToken(\\n _name,\\n _symbol,\\n _totalSupply,\\n _tradingStartsAt,\\n address(vaporDexAggregator),\\n vaporDexAdapter\\n );\\n _tokenAddress = address(_token);\\n\\n // Step 2: Create the pair\\n IVaporDEXFactory _factory = IVaporDEXFactory(factory);\\n _pair = _factory.createPair(_tokenAddress, address(WETH));\\n _token.approve(router, _totalSupply);\\n _token.approve(_pair, _totalSupply);\\n\\n // Step 2: Add Liquidity\\n IVaporDEXRouter _router = IVaporDEXRouter(router);\\n _router.addLiquidityETH{value: msg.value}(\\n _tokenAddress,\\n _totalSupply,\\n _totalSupply,\\n msg.value,\\n address(this),\\n block.timestamp + 10 minutes\\n );\\n // Step 3: Get the pair address\\n _pair = _factory.getPair(_tokenAddress, address(WETH));\\n if (_pair == address(0)) {\\n revert TokenFactory__ZeroAddress();\\n }\\n // Step 4: Set the LP address in the token\\n _token.setLiquidityPool(_pair);\\n // Step 5: Renounce ownership of the token\\n _token.renounceOwnership();\\n\\n // Step 6: Lock Or Burn Liquidity\\n\\n IERC20 _lpToken = IERC20(_pair);\\n\\n if (_burnLiquidity) {\\n // Burn Liquidity\\n _lpToken.transfer(address(0), _lpToken.balanceOf(address(this)));\\n emit LiquidityBurned(\\n _pair,\\n msg.sender,\\n _lpToken.balanceOf(address(this))\\n );\\n } else {\\n if (lockDuration < minLockDuration) {\\n revert TokenFactory__MinimumLockDuration();\\n }\\n _lpToken.approve(\\n address(sablier),\\n _lpToken.balanceOf(address(this))\\n );\\n // Lock Liquidity\\n // SablierV2\\n LockupLinear.CreateWithDurations memory params;\\n\\n // Declare the function parameters\\n params.sender = address(this); // The sender will be able to cancel the stream\\n params.recipient = msg.sender; // The recipient of the streamed assets\\n params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees\\n params.asset = _lpToken; // The streaming asset\\n params.cancelable = false; // Whether the stream will be cancelable or not\\n params.transferable = true; // Whether the stream will be transferrable or not\\n params.durations = LockupLinear.Durations({\\n cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period\\n total: lockDuration * 1 days\\n });\\n\\n // Create the stream\\n streamId = sablier.createWithDurations(params);\\n liquidityLocks[msg.sender][_pair] = streamId;\\n\\n emit StreamCreated(streamId, msg.sender, _pair);\\n }\\n\\n // Step 7: Buy VAPE with USDC on VaporDEXAggregator\\n\\n _buyVapeWithUsdc(launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee\\n\\n // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2\\n\\n _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract\\n\\n // Step 9: Store the token launch\\n emit TokenLaunched(_tokenAddress, msg.sender, tokenCounter);\\n\\n addressToCounters[msg.sender].push(tokenCounter);\\n counterToAddress[tokenCounter] = msg.sender;\\n tokenCounter++;\\n }\\n\\n /**\\n * @dev Unlocks liquidity tokens for the specified pair and recipient.\\n * @param _pair Address of the token pair.\\n * @param _receiver Address of the recipient of unlocked tokens.\\n * @notice It is recommended to direct the user to Sablier UI for better error handling.\\n */\\n function unlockLiquidityTokens(address _pair, address _receiver) external {\\n if (_receiver == address(0)) {\\n revert TokenFactory__ZeroAddress();\\n }\\n uint256 streamId = liquidityLocks[msg.sender][_pair];\\n\\n if (streamId == 0) {\\n revert TokenFactory__Unauthorized();\\n }\\n\\n uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\\n if (withdrawableAmount == 0) {\\n revert TokenFactory__LiquidityLockedOrDepleted();\\n }\\n\\n sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier\\n\\n emit LiquidityTokensUnlocked(_pair, _receiver);\\n }\\n\\n /**\\n * @dev Transfers the locked liquidity to the specified recipient for the given pair.\\n * @param _pair Address of the token pair.\\n * @param _to Address of the recipient.\\n */\\n function transferLock(address _pair, address _to) external {\\n uint256 streamId = liquidityLocks[msg.sender][_pair];\\n if (\\n streamId == 0 ||\\n _to == address(0) ||\\n sablier.isTransferable(streamId) == false\\n ) {\\n revert TokenFactory__Unauthorized();\\n }\\n\\n liquidityLocks[_to][_pair] = streamId;\\n liquidityLocks[msg.sender][_pair] = 0;\\n\\n sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier\\n\\n emit LiquidityTransferred(_pair, _to);\\n }\\n\\n /**\\n * @dev Sets the minimum liquidity for creating new tokens.\\n * @param _liquidity New liquidity.\\n */\\n\\n function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner {\\n if (_liquidity == 0) {\\n revert TokenFactory__Invalid();\\n }\\n minLiquidityETH = _liquidity;\\n emit MinimumLiquidityETHUpdated(_liquidity);\\n }\\n\\n /**\\n * @dev Sets the minimum liquidity for creating new tokens.\\n * @param _slippage New lock duration in days.\\n */\\n\\n function setSlippage(uint256 _slippage) external onlyOwner {\\n slippage = _slippage;\\n emit SlippageUpdated(_slippage);\\n }\\n\\n /**\\n * @dev Sets the minimum liquidity for creating new tokens.\\n * @param _lockDuration New lock duration in days.\\n */\\n\\n function setMinLockDuration(uint40 _lockDuration) external onlyOwner {\\n if (_lockDuration == 0) {\\n revert TokenFactory__Invalid();\\n }\\n minLockDuration = _lockDuration;\\n emit MinimumLockDurationUpdated(_lockDuration);\\n }\\n\\n /**\\n * @dev Sets the launch fee for creating new tokens.\\n * @param _launchFee New launch fee in USDC.\\n */\\n\\n function setLaunchFee(uint256 _launchFee) external onlyOwner {\\n if (_launchFee == 0) {\\n revert TokenFactory__Invalid();\\n }\\n launchFee = _launchFee;\\n emit LaunchFeeUpdated(_launchFee);\\n }\\n\\n /**\\n * @dev Sets the VaporDEX adapter address.\\n * @param _vaporDexAdapter New VaporDEX adapter address.\\n */\\n\\n function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner {\\n if (\\n _vaporDexAdapter == vaporDexAdapter ||\\n _vaporDexAdapter == address(0)\\n ) {\\n revert TokenFactory__Invalid();\\n }\\n vaporDexAdapter = _vaporDexAdapter;\\n emit VaporDEXAdapterUpdated(_vaporDexAdapter);\\n }\\n\\n /**\\n * @dev Withdraws any stuck tokens (LP Or USDC) to the specified address.\\n * @param _token Address of the token to be withdrawn.\\n * @param _to Address to which the tokens are withdrawn.\\n */\\n\\n function emergencyWithdraw(address _token, address _to) external onlyOwner {\\n if (_to == address(0) || _token == address(0)) {\\n revert TokenFactory__ZeroAddress();\\n }\\n IERC20 token = IERC20(_token);\\n uint256 balance = token.balanceOf(address(this));\\n if (balance == 0) {\\n revert TokenFactory__InsufficientBalance();\\n }\\n token.transfer(_to, balance);\\n emit EmergencyWithdraw(_token, token.balanceOf(address(this)), _to);\\n }\\n\\n /**\\n * @dev Creates a new Token contract with specified parameters.\\n * @param name Name of the token.\\n * @param symbol Symbol of the token.\\n * @param totalSupply Total supply of the token.\\n * @param _tradingStartsAt Timestamp when trading starts for the token.\\n * @param dexAggregator Address of the decentralized exchange aggregator.\\n * @param dexAdapter Address of the decentralized exchange adapter.\\n * @return _token Instance of the created Token contract.\\n */\\n function _createToken(\\n string memory name,\\n string memory symbol,\\n uint256 totalSupply,\\n uint256 _tradingStartsAt,\\n address dexAggregator,\\n address dexAdapter\\n ) internal returns (Token _token) {\\n if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) {\\n revert TokenFactory__WrongLaunchArguments();\\n }\\n _token = new Token(\\n name,\\n symbol,\\n totalSupply,\\n stratosphere,\\n address(this),\\n _tradingStartsAt,\\n dexAggregator,\\n dexAdapter\\n );\\n }\\n\\n /**\\n * @dev Transfers the launch fee in USDC from the sender.\\n * @param _from Address from which the launch fee is transferred.\\n */\\n\\n function _transferLaunchFee(address _from) internal {\\n IERC20 _usdc = IERC20(USDC);\\n if (_usdc.balanceOf(_from) < launchFee) {\\n revert TokenFactory__InsufficientBalance();\\n }\\n bool isSuccess = _usdc.transferFrom(_from, address(this), launchFee);\\n if (!isSuccess) {\\n revert TokenFactory__TranferFailed(_from);\\n }\\n }\\n\\n /**\\n * @dev Buys VAPE with USDC on VaporDEXAggregator\\n * @param amountIn Amount of USDC to be used for buying VAPE.\\n */\\n\\n function _buyVapeWithUsdc(uint256 amountIn) internal {\\n USDC.approve(address(vaporDexAggregator), amountIn);\\n\\n IDexAggregator.FormattedOffer memory offer = vaporDexAggregator\\n .findBestPath(\\n amountIn,\\n address(USDC),\\n address(VAPE),\\n 1 // can be changed to 3\\n );\\n IDexAggregator.Trade memory trade;\\n trade.amountIn = amountIn;\\n trade.amountOut = offer.amounts[offer.amounts.length - 1];\\n trade.path = offer.path;\\n trade.adapters = offer.adapters;\\n vaporDexAggregator.swapNoSplit(trade, address(this), 0);\\n }\\n\\n /**\\n * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2.\\n * @notice Uses the balance of VAPE and USDC in the contract.\\n */\\n\\n function _addLiquidityVapeUsdc() internal {\\n uint256 amountInUSDC = USDC.balanceOf(address(this));\\n uint256 amountInVAPE = VAPE.balanceOf(address(this));\\n USDC.approve(address(nonFungiblePositionManager), amountInUSDC);\\n VAPE.approve(address(nonFungiblePositionManager), amountInVAPE);\\n INonfungiblePositionManager.MintParams\\n memory mintParams = INonfungiblePositionManager.MintParams({\\n token0: address(VAPE),\\n token1: address(USDC),\\n fee: 3000,\\n tickLower: -887220, // full range\\n tickUpper: 887220, // full range\\n amount0Desired: amountInVAPE,\\n amount1Desired: amountInUSDC,\\n amount0Min: amountInVAPE - _percentage(amountInVAPE, slippage), // 2% slippage\\n amount1Min: amountInUSDC - _percentage(amountInUSDC, slippage), // 2% slippage\\n recipient: teamMultisig,\\n deadline: block.timestamp + 2 minutes\\n });\\n nonFungiblePositionManager.mint(mintParams);\\n\\n // Q: What checks should be done with the return values?\\n }\\n\\n function _percentage(\\n uint256 _number,\\n uint256 _percentageBasisPoints // Example: 1% is 100\\n ) internal pure returns (uint256) {\\n return (_number * _percentageBasisPoints) / 10_000;\\n }\\n\\n // Getters\\n\\n /**\\n * @dev Returns the launch fee.\\n * @return uint256 The launch fee.\\n */\\n function getLaunchFee() external view returns (uint256) {\\n return launchFee;\\n }\\n\\n /**\\n * @dev Returns the address of the VaporDEX adapter.\\n * @return address The address of the VaporDEX adapter.\\n */\\n function getVaporDexAdapter() external view returns (address) {\\n return vaporDexAdapter;\\n }\\n\\n /**\\n * @dev Returns the address of the VaporDEX router.\\n * @return address The address of the VaporDEX router.\\n */\\n function getVaporDEXRouter() external view returns (address) {\\n return router;\\n }\\n\\n /**\\n * @dev Returns the address of the VaporDEX factory.\\n * @return address The address of the VaporDEX factory.\\n */\\n function getVaporDEXFactory() external view returns (address) {\\n return factory;\\n }\\n\\n /**\\n * @dev Returns the address of the Stratosphere contract.\\n * @return address The address of the Stratosphere contract.\\n */\\n function getStratosphere() external view returns (address) {\\n return stratosphere;\\n }\\n\\n /**\\n * @dev Returns the address of the VaporDEX aggregator.\\n * @return address The address of the VaporDEX aggregator.\\n */\\n function getVaporDexAggregator() external view returns (address) {\\n return address(vaporDexAggregator);\\n }\\n\\n /**\\n * @dev Returns the address of the USDC token.\\n * @return address The address of the USDC token.\\n */\\n function getUSDC() external view returns (address) {\\n return address(USDC);\\n }\\n\\n /**\\n * @dev Returns the address of the VAPE token.\\n * @return address The address of the VAPE token.\\n */\\n function getVAPE() external view returns (address) {\\n return address(VAPE);\\n }\\n\\n /**\\n * @dev Returns the address of the VaporDEX adapter.\\n * @return address The address of the VaporDEX adapter.\\n */\\n function getVaporDEXAdapter() external view returns (address) {\\n return vaporDexAdapter;\\n }\\n\\n /**\\n * @dev Returns the address of the team multisig wallet.\\n * @return address The address of the team multisig wallet.\\n */\\n function getTeamMultisig() external view returns (address) {\\n return teamMultisig;\\n }\\n\\n /**\\n * @dev Returns the address of the Sablier contract.\\n * @return address The address of the Sablier contract.\\n */\\n function getSablier() external view returns (address) {\\n return address(sablier);\\n }\\n\\n /**\\n * @dev Returns the address of the NonFungiblePositionManager contract.\\n * @return address The address of the NonFungiblePositionManager contract.\\n */\\n function getNonFungiblePositionManager() external view returns (address) {\\n return address(nonFungiblePositionManager);\\n }\\n\\n /**\\n * @dev Returns the liquidity lock for the specified pair and owner.\\n * @param _pair Address of the token pair.\\n * @param _owner Address of the owner.\\n * @return uint256 Stream ID for the liquidity lock.\\n */\\n\\n function getLiquidityLock(\\n address _pair,\\n address _owner\\n ) external view returns (uint256) {\\n return liquidityLocks[_owner][_pair];\\n }\\n\\n function getTokenLaunch(\\n address _owner\\n ) external view returns (uint256[] memory) {\\n return addressToCounters[_owner];\\n }\\n\\n function getCounterToAddress(\\n uint256 _counter\\n ) external view returns (address) {\\n return counterToAddress[_counter];\\n }\\n}\\n\",\"keccak256\":\"0xd9bd552ae39f9dc67ab4d6d83cecd7bee682ea5c95d1e235641c0b8ccb9e8651\",\"license\":\"MIT\"},\"contracts/interfaces/IDexAggregator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IDexAggregator {\\n struct FormattedOffer {\\n uint256[] amounts;\\n address[] adapters;\\n address[] path;\\n uint256 gasEstimate;\\n }\\n\\n struct Trade {\\n uint256 amountIn;\\n uint256 amountOut;\\n address[] path;\\n address[] adapters;\\n }\\n\\n function findBestPath(\\n uint256 _amountIn,\\n address _tokenIn,\\n address _tokenOut,\\n uint256 _maxSteps\\n ) external view returns (FormattedOffer memory);\\n\\n function swapNoSplitFromAVAX(\\n Trade calldata _trade,\\n address _to,\\n uint256 _fee\\n ) external payable;\\n\\n function swapNoSplitToAVAX(\\n Trade calldata _trade,\\n address _to,\\n uint256 _fee\\n ) external;\\n\\n function swapNoSplit(\\n Trade calldata _trade,\\n address _to,\\n uint256 _fee\\n ) external;\\n}\\n\",\"keccak256\":\"0xbddad15c495223fb81e453b5539f8ad91b2dc33591d4ed3a3bae28352939b5e9\",\"license\":\"MIT\"},\"contracts/interfaces/INonfungiblePositionManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\n/// @title Non-fungible token for positions\\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\\n/// and authorized.\\ninterface INonfungiblePositionManager {\\n struct MintParams {\\n address token0;\\n address token1;\\n uint24 fee;\\n int24 tickLower;\\n int24 tickUpper;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n address recipient;\\n uint256 deadline;\\n }\\n\\n /// @notice Creates a new position wrapped in a NFT\\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\\n /// a method does not exist, i.e. the pool is assumed to be initialized.\\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\\n /// @return tokenId The ID of the token that represents the minted position\\n /// @return liquidity The amount of liquidity for this position\\n /// @return amount0 The amount of token0\\n /// @return amount1 The amount of token1\\n function mint(\\n MintParams calldata params\\n )\\n external\\n payable\\n returns (\\n uint256 tokenId,\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n}\\n\",\"keccak256\":\"0x52a12b9be3201a7d8ee7a209f96d53472b785796617f21e2fba5904afc5d9a6a\",\"license\":\"GPL-2.0-or-later\"},\"contracts/interfaces/IStratosphere.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IStratosphere {\\n function tokenIdOf(address _owner) external view returns (uint256);\\n\\n function mint() external returns (uint256);\\n}\\n\",\"keccak256\":\"0xcdeae2f910ab65598f3411188d6157659bc10ed9cdec3c86bb30c9296d02fae5\",\"license\":\"MIT\"},\"contracts/interfaces/IVaporDEXFactory.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IVaporDEXFactory {\\n function createPair(\\n address tokenA,\\n address tokenB\\n ) external returns (address pair);\\n\\n function getPair(\\n address tokenA,\\n address tokenB\\n ) external view returns (address pair);\\n}\\n\",\"keccak256\":\"0x5a74950275714f40d7816d1dfbc655cdcc9b59e2815c37add476ad60798caca4\",\"license\":\"MIT\"},\"contracts/interfaces/IVaporDEXRouter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IVaporDEXRouter {\\n function factory() external view returns (address);\\n\\n function WETH() external view returns (address);\\n\\n function addLiquidityETH(\\n address token,\\n uint256 amountTokenDesired,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n )\\n external\\n payable\\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\\n}\\n\",\"keccak256\":\"0xfc9f2a276adeac02412fe44d82c82b3edfd0123a6ef4f55c641ad5ab7fa9d127\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x6101a060405234801561001157600080fd5b506040516161e13803806161e1833981016040819052610030916103b6565b80516001600160a01b03811661006057604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b610069816102fe565b5080516001600160a01b0316158061008c575060208101516001600160a01b0316155b806100a2575060408101516001600160a01b0316155b806100b8575060608101516001600160a01b0316155b806100ce575060808101516001600160a01b0316155b806100e4575060a08101516001600160a01b0316155b806100f1575060e0810151155b8061010857506101408101516001600160a01b0316155b806101165750610100810151155b8061012b575061012081015164ffffffffff16155b15610149576040516364ad04f960e11b815260040160405180910390fd5b6101a0810151600555602080820180516001600160a01b0390811660a05290516040805163c45a015560e01b8152905191939284169263c45a0155926004808401938290030181865afa1580156101a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c891906104b4565b6001600160a01b03166080816001600160a01b031681525050806001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561021f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024391906104b4565b6001600160a01b0390811661012090815260a0840151821661014090815260c080860151841661016090815261010080880151600455938701516006805464ffffffffff191664ffffffffff909216919091179055604087015185169091526060860151841660e09081526080870151600180546001600160a01b03199081169288169290921790559087015160035591860151841661018090815290860151841690925293015160028054909416911617909155506104d6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516101c081016001600160401b038111828210171561037f57634e487b7160e01b600052604160045260246000fd5b60405290565b80516001600160a01b038116811461039c57600080fd5b919050565b805164ffffffffff8116811461039c57600080fd5b60006101c082840312156103c957600080fd5b6103d161034e565b6103da83610385565b81526103e860208401610385565b60208201526103f960408401610385565b604082015261040a60608401610385565b606082015261041b60808401610385565b608082015261042c60a08401610385565b60a082015261043d60c08401610385565b60c082015260e083015160e08201526101008084015181830152506101206104668185016103a1565b90820152610140610478848201610385565b9082015261016061048a848201610385565b9082015261018061049c848201610385565b908201526101a0928301519281019290925250919050565b6000602082840312156104c657600080fd5b6104cf82610385565b9392505050565b60805160a05160c05160e0516101005161012051610140516101605161018051615bd761060a600039600081816104b801528181611015015281816112de01528181611682015281816117c801528181611c9e0152611db8015260008181610430015281816123c00152818161269a0152818161285001526128ce0152600081816102ad01528181612019015281816122e601528181612398015281816125d101528181612774015261290a0152600081816108990152610bdb01526000818161069e01528181612742015281816128210152612a330152600081816105940152818161080d015281816122b7015281816123f2015261252f01526000818161037a015261221201526000818161052b015281816109730152610a900152600081816101ec01526108c70152615bd76000f3fe6080604052600436106101d85760003560e01c80636382d9ad11610102578063bdefc19011610095578063e77c7cd211610064578063e77c7cd214610622578063f0fa55a91461064f578063f2fde38b1461066f578063f984bc051461068f57600080fd5b8063bdefc19014610585578063d082e381146105b8578063d586c5f1146105ce578063d6a298e9146105ee57600080fd5b80638da5cb5b116100d15780638da5cb5b146104f15780639157742a1461051c5780639cec7a171461054f578063bd26b7951461056557600080fd5b80636382d9ad14610474578063715018a6146104945780638051a3ad146104a957806388dcaa6d146104dc57600080fd5b80633e032a3b1161017a5780635313be2c116101495780635313be2c14610401578063581c5959146102f15780635af91370146104215780635caab6be1461045457600080fd5b80633e032a3b146103475780633ebdf71f1461036b57806340f0519c1461039e57806344e35618146103e157600080fd5b80631bf01e9b116101b65780631bf01e9b1461029e5780631fef0820146102d157806331540bf3146102f1578063328f0d3a1461031c57600080fd5b80630edba8ce146101dd578063121b40b6146102365780631867937c14610258575b600080fd5b3480156101e957600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561024257600080fd5b50610256610251366004612b6f565b6106c2565b005b61026b610266366004612ce9565b6107b8565b6040805173ffffffffffffffffffffffffffffffffffffffff94851681529390921660208401529082015260600161022d565b3480156102aa57600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156102dd57600080fd5b506102566102ec366004612d84565b61149d565b3480156102fd57600080fd5b5060015473ffffffffffffffffffffffffffffffffffffffff1661020c565b34801561032857600080fd5b5060025473ffffffffffffffffffffffffffffffffffffffff1661020c565b34801561035357600080fd5b5061035d60055481565b60405190815260200161022d565b34801561037757600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156103aa57600080fd5b5061020c6103b9366004612d9f565b60009081526009602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b3480156103ed57600080fd5b5061035d6103fc366004612db8565b61154a565b34801561040d57600080fd5b5061025661041c366004612d9f565b611584565b34801561042d57600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b34801561046057600080fd5b5061025661046f366004612db8565b6115fb565b34801561048057600080fd5b5061025661048f366004612db8565b611870565b3480156104a057600080fd5b50610256611b29565b3480156104b557600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156104e857600080fd5b5060035461035d565b3480156104fd57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff1661020c565b34801561052857600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b34801561055b57600080fd5b5061035d60045481565b34801561057157600080fd5b50610256610580366004612d9f565b611b3d565b34801561059157600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156105c457600080fd5b5061035d60075481565b3480156105da57600080fd5b506102566105e9366004612db8565b611bb4565b3480156105fa57600080fd5b5060065461060c9064ffffffffff1681565b60405164ffffffffff909116815260200161022d565b34801561062e57600080fd5b5061064261063d366004612b6f565b611e5f565b60405161022d9190612df1565b34801561065b57600080fd5b5061025661066a366004612d9f565b611ed8565b34801561067b57600080fd5b5061025661068a366004612b6f565b611f15565b34801561069b57600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b6106ca611f7e565b60015473ffffffffffffffffffffffffffffffffffffffff82811691161480610707575073ffffffffffffffffffffffffffffffffffffffff8116155b1561073e576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdbe246cfe804b22936a913bd3b7c4afe2ff6632dcf29b6ec8dc2fff938161e3a906020015b60405180910390a150565b60008060006004543410156107f9576040517faee4b66100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61080233611fd1565b60006108548a8a8a8a7f0000000000000000000000000000000000000000000000000000000000000000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166121bc565b6040517fc9c6539600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301527f0000000000000000000000000000000000000000000000000000000000000000811660248301529194508492507f00000000000000000000000000000000000000000000000000000000000000009182169063c9c65396906044016020604051808303816000875af1158015610912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109369190612e35565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018c90529196509083169063095ea7b3906044016020604051808303816000875af11580156109cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f39190612e52565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018b905283169063095ea7b3906044016020604051808303816000875af1158015610a69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8d9190612e52565b507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff811663f305d71934878d808330610add42610258612e9e565b60405160e089901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff9687166004820152602481019590955260448501939093526064840191909152909216608482015260a481019190915260c40160606040518083038185885af1158015610b6f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610b949190612eb1565b50506040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301527f0000000000000000000000000000000000000000000000000000000000000000811660248301528416915063e6a4390590604401602060405180830381865afa158015610c2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4f9190612e35565b955073ffffffffffffffffffffffffffffffffffffffff8616610c9e576040517fafc19a6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f0187702000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152841690630187702090602401600060405180830381600087803b158015610d0757600080fd5b505af1158015610d1b573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663715018a66040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610d6757600080fd5b505af1158015610d7b573d6000803e3d6000fd5b508892505088159050610f82576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063a9059cbb9060009083906370a0823190602401602060405180830381865afa158015610dfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e219190612edf565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af1158015610e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb59190612e52565b506040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152339073ffffffffffffffffffffffffffffffffffffffff898116917fd289537cc1c5d4ce83b387cec5cdc2658a741cf986d6ad8521af47b377be7ef6918516906370a0823190602401602060405180830381865afa158015610f48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6c9190612edf565b60405190815260200160405180910390a36113b6565b60065464ffffffffff908116908a161015610fc9576040517f25d66d2c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063095ea7b3907f00000000000000000000000000000000000000000000000000000000000000009083906370a0823190602401602060405180830381865afa15801561105d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110819190612edf565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af11580156110f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111159190612e52565b50611178604080516101008101825260008082526020808301829052828401829052606083018290526080830182905260a083018290528351808501855282815280820183905260c084015283518085019094528184528301529060e082015290565b308082523360208301526040517f70a08231000000000000000000000000000000000000000000000000000000008152600481019190915273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156111ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112129190612edf565b6fffffffffffffffffffffffffffffffff1660408083019190915273ffffffffffffffffffffffffffffffffffffffff8316606083015260006080830152600160a08301819052815180830190925281906112708d62015180612ef8565b61127a9190612f21565b64ffffffffff1681526020016112938c62015180612ef8565b64ffffffffff16905260c08201526040517fab167ccc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063ab167ccc90611313908490600401612f46565b6020604051808303816000875af1158015611332573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113569190612edf565b336000818152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8e168085529252808320859055519399509289917f39679ae33cd13645ec63a701454bd16e6beb24116d89b21c45edb2647cf0bd2e91a4505b6113cd60026003546113c89190613021565b61227a565b6113d56125a0565b600754604051339073ffffffffffffffffffffffffffffffffffffffff8916907f1a780177e5001bb4f067da390710f31a74a35b48fe52f49d5b60e854744f115490600090a433600081815260086020908152604080832060078054825460018101845592865284862090920191909155805484526009909252822080547fffffffffffffffffffffffff000000000000000000000000000000000000000016909317909255815491906114888361305c565b91905055505050505096509650969350505050565b6114a5611f7e565b8064ffffffffff166000036114e6576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff83169081179091556040519081527f73e38b32aad3b3e0d429bc819e2d79b4712f86c083bacf669d22ab304fe5888d906020016107ad565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152600a60209081526040808320938616835292905220545b92915050565b61158c611f7e565b806000036115c6576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60038190556040518181527fc799be5eb19a1a6d6ba7368d21e2bc367c8a335e4a07cd3d954482e6f714d3c5906020016107ad565b336000908152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915290205480158061164d575073ffffffffffffffffffffffffffffffffffffffff8216155b8061170457506040517fb2564569000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063b256456990602401602060405180830381865afa1580156116de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117029190612e52565b155b1561173b576040517f686ad40700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8281166000818152600a60208181526040808420898716808652908352818520889055338086529383528185209085529091528083209290925590517f23b872dd00000000000000000000000000000000000000000000000000000000815260048101919091526024810191909152604481018390527f0000000000000000000000000000000000000000000000000000000000000000909116906323b872dd90606401600060405180830381600087803b15801561180e57600080fd5b505af1158015611822573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff8086169350861691507f41f8af339a1fd0d4ed41d2aec5c89989b96536e24958255ed584080bb2c1623190600090a3505050565b611878611f7e565b73ffffffffffffffffffffffffffffffffffffffff811615806118af575073ffffffffffffffffffffffffffffffffffffffff8216155b156118e6576040517fafc19a6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829060009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015611955573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119799190612edf565b9050806000036119b5576040517f9f4ef32900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af1158015611a2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4e9190612e52565b506040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff80851691908416906370a0823190602401602060405180830381865afa158015611abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae29190612edf565b60405173ffffffffffffffffffffffffffffffffffffffff8716907faaeda929aa102e867049528ec7cd2499e3a2f8846e736ae7935f234dfbf500d990600090a450505050565b611b31611f7e565b611b3b6000612aab565b565b611b45611f7e565b80600003611b7f576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60048190556040518181527f1fd55d90af4abf6458d9caa4afe3590d7a8ea749b373a53114a7273fe7c8b631906020016107ad565b73ffffffffffffffffffffffffffffffffffffffff8116611c01576040517fafc19a6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000908152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003611c6c576040517f686ad40700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fd975dfed000000000000000000000000000000000000000000000000000000008152600481018290526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063d975dfed90602401602060405180830381865afa158015611cfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1e91906130b4565b6fffffffffffffffffffffffffffffffff16905080600003611d6c576040517f21b34bd500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fea5ead190000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff84811660248301527f0000000000000000000000000000000000000000000000000000000000000000169063ea5ead1990604401600060405180830381600087803b158015611dfc57600080fd5b505af1158015611e10573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff8087169350871691507ff58c2894662c00ada7f78292cc1d18f7de0ff41bf57e6bcb13e7cda455d8a59090600090a350505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260086020908152604091829020805483518184028101840190945280845260609392830182828015611ecc57602002820191906000526020600020905b815481526020019060010190808311611eb8575b50505050509050919050565b611ee0611f7e565b60058190556040518181527ff5a802650e0a86db227cc342f06327d2ca0ff5cf2b12e0084fc5d8a7db2c54fd906020016107ad565b611f1d611f7e565b73ffffffffffffffffffffffffffffffffffffffff8116611f72576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b611f7b81612aab565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314611b3b576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611f69565b6003546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f00000000000000000000000000000000000000000000000000000000000000009291908316906370a0823190602401602060405180830381865afa158015612064573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120889190612edf565b10156120c0576040517f9f4ef32900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015230602483015260448201929092526000918316906323b872dd906064016020604051808303816000875af1158015612142573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121669190612e52565b9050806121b7576040517f61fa4c0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401611f69565b505050565b60008415806121d657506121d3426202a300612e9e565b84105b1561220d576040517fcff90ad900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8686867f00000000000000000000000000000000000000000000000000000000000000003088888860405161224190612b40565b612252989796959493929190613133565b604051809103906000f08015801561226e573d6000803e3d6000fd5b50979650505050505050565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303816000875af115801561232f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123539190612e52565b506040517f4c09cf4e0000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660248301527f000000000000000000000000000000000000000000000000000000000000000081166044830152600160648301526000917f000000000000000000000000000000000000000000000000000000000000000090911690634c09cf4e90608401600060405180830381865afa15801561243b573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526124819190810190613244565b90506124ae6040518060800160405280600081526020016000815260200160608152602001606081525090565b828152815180516124c190600190613359565b815181106124d1576124d161336c565b6020908102919091018101518282015260408084015181840152908301516060830152517f6bf2df8600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690636bf2df869061256990849030906000906004016133ed565b600060405180830381600087803b15801561258357600080fd5b505af1158015612597573d6000803e3d6000fd5b50505050505050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa15801561262d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126519190612edf565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156126e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127059190612edf565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018590529192507f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af11580156127bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e39190612e52565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303816000875af1158015612899573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128bd9190612e52565b5060006040518061016001604052807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1681526020017f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168152602001610bb862ffffff1681526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c60020b8152602001620d89b460020b815260200183815260200184815260200161299e84600554612b20565b6129a89085613359565b81526020016129b985600554612b20565b6129c39086613359565b815260025473ffffffffffffffffffffffffffffffffffffffff1660208201526040016129f1426078612e9e565b90526040517f8831645600000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690638831645690612a68908490600401613482565b6080604051808303816000875af1158015612a87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612597919061356d565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000612710612b2f83856135a9565b612b399190613021565b9392505050565b6125e1806135c183390190565b73ffffffffffffffffffffffffffffffffffffffff81168114611f7b57600080fd5b600060208284031215612b8157600080fd5b8135612b3981612b4d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715612bde57612bde612b8c565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715612c2b57612c2b612b8c565b604052919050565b600082601f830112612c4457600080fd5b813567ffffffffffffffff811115612c5e57612c5e612b8c565b612c8f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612be4565b818152846020838601011115612ca457600080fd5b816020850160208301376000918101602001919091529392505050565b803564ffffffffff81168114612cd657600080fd5b919050565b8015158114611f7b57600080fd5b60008060008060008060c08789031215612d0257600080fd5b863567ffffffffffffffff80821115612d1a57600080fd5b612d268a838b01612c33565b97506020890135915080821115612d3c57600080fd5b50612d4989828a01612c33565b9550506040870135935060608701359250612d6660808801612cc1565b915060a0870135612d7681612cdb565b809150509295509295509295565b600060208284031215612d9657600080fd5b612b3982612cc1565b600060208284031215612db157600080fd5b5035919050565b60008060408385031215612dcb57600080fd5b8235612dd681612b4d565b91506020830135612de681612b4d565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b81811015612e2957835183529284019291840191600101612e0d565b50909695505050505050565b600060208284031215612e4757600080fd5b8151612b3981612b4d565b600060208284031215612e6457600080fd5b8151612b3981612cdb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561157e5761157e612e6f565b600080600060608486031215612ec657600080fd5b8351925060208401519150604084015190509250925092565b600060208284031215612ef157600080fd5b5051919050565b64ffffffffff818116838216028082169190828114612f1957612f19612e6f565b505092915050565b64ffffffffff828116828216039080821115612f3f57612f3f612e6f565b5092915050565b60006101408201905073ffffffffffffffffffffffffffffffffffffffff8084511683528060208501511660208401526fffffffffffffffffffffffffffffffff6040850151166040840152806060850151166060840152506080830151612fb2608084018215159052565b5060a0830151612fc660a084018215159052565b5060c0830151612fed60c0840182805164ffffffffff908116835260209182015116910152565b5060e0830151805173ffffffffffffffffffffffffffffffffffffffff166101008401526020810151610120840152612f3f565b600082613057577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361308d5761308d612e6f565b5060010190565b80516fffffffffffffffffffffffffffffffff81168114612cd657600080fd5b6000602082840312156130c657600080fd5b612b3982613094565b6000815180845260005b818110156130f5576020818501810151868301820152016130d9565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b60006101008083526131478184018c6130cf565b9050828103602084015261315b818b6130cf565b6040840199909952505073ffffffffffffffffffffffffffffffffffffffff9586166060820152938516608085015260a0840192909252831660c083015290911660e09091015292915050565b600067ffffffffffffffff8211156131c2576131c2612b8c565b5060051b60200190565b600082601f8301126131dd57600080fd5b815160206131f26131ed836131a8565b612be4565b8083825260208201915060208460051b87010193508684111561321457600080fd5b602086015b8481101561323957805161322c81612b4d565b8352918301918301613219565b509695505050505050565b6000602080838503121561325757600080fd5b825167ffffffffffffffff8082111561326f57600080fd5b908401906080828703121561328357600080fd5b61328b612bbb565b82518281111561329a57600080fd5b8301601f810188136132ab57600080fd5b80516132b96131ed826131a8565b81815260059190911b8201860190868101908a8311156132d857600080fd5b928701925b828410156132f6578351825292870192908701906132dd565b8452505050828401518281111561330c57600080fd5b613318888286016131cc565b8583015250604083015193508184111561333157600080fd5b61333d878585016131cc565b6040820152606083015160608201528094505050505092915050565b8181038181111561157e5761157e612e6f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008151808452602080850194506020840160005b838110156133e257815173ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016133b0565b509495945050505050565b60608152835160608201526020840151608082015260006040850151608060a084015261341d60e084018261339b565b905060608601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08483030160c0850152613458828261339b565b73ffffffffffffffffffffffffffffffffffffffff96909616602085015250505060400152919050565b815173ffffffffffffffffffffffffffffffffffffffff168152610160810160208301516134c8602084018273ffffffffffffffffffffffffffffffffffffffff169052565b5060408301516134df604084018262ffffff169052565b5060608301516134f4606084018260020b9052565b506080830151613509608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e08301526101008084015181840152506101208084015161355c8285018273ffffffffffffffffffffffffffffffffffffffff169052565b505061014092830151919092015290565b6000806000806080858703121561358357600080fd5b8451935061359360208601613094565b6040860151606090960151949790965092505050565b808202811582820484141761157e5761157e612e6f56fe61020060405234801561001157600080fd5b506040516125e13803806125e183398101604081905261003091610752565b838880604051806040016040528060018152602001603160f81b8152508b8b816003908161005e9190610895565b50600461006b8282610895565b5061007b915083905060056101a7565b6101205261008a8160066101a7565b61014052815160208084019190912060e052815190820120610100524660a05261011760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506001600160a01b03811661015057604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610159816101da565b506001600160a01b0385166101e052610172338761022c565b61017d866064610266565b6101a0526101c0929092526001600160a01b0390811661016052166101805250610a399350505050565b60006020835110156101c3576101bc83610286565b90506101d4565b816101ce8482610895565b5060ff90505b92915050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166102565760405163ec442f0560e01b815260006004820152602401610147565b610262600083836102c4565b5050565b6000612710610275838561096a565b61027f9190610981565b9392505050565b600080829050601f815111156102b1578260405163305a27a960e01b815260040161014791906109a3565b80516102bc826109d6565b179392505050565b6102cf838383610415565b6101c0516009546001600160a01b031661036a576008546001600160a01b038581169116148061030c57506008546001600160a01b038481169116145b6103645760405162461bcd60e51b815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201526265742160e81b6064820152608401610147565b50505050565b8042101561038b5760405163f67ab97f60e01b815260040160405180910390fd5b600061039782426109fa565b9050620151808111156103ab575050505050565b610e108110156103f9576103bf848461053f565b6103c8856105a3565b80156103d857506103d8846105a3565b6103f457604051620abbc160e51b815260040160405180910390fd5b61040e565b6201518081101561040e5761040e848461053f565b5050505050565b6001600160a01b0383166104405780600260008282546104359190610a0d565b909155506104b29050565b6001600160a01b038316600090815260208190526040902054818110156104935760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610147565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166104ce576002805482900390556104ed565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161053291815260200190565b60405180910390a3505050565b6009546001600160a01b03838116911614610262576001600160a01b038216600090815260208190526040812054610578908390610a0d565b90506101a05181111561059e5760405163b7eae0d360e01b815260040160405180910390fd5b505050565b6000610160516001600160a01b0316826001600160a01b031614806105dc5750610180516001600160a01b0316826001600160a01b0316145b8061065457506101e051604051631dcf00b560e21b81526001600160a01b0384811660048301529091169063773c02d490602401602060405180830381865afa15801561062d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106519190610a20565b15155b8061066c57506009546001600160a01b038381169116145b15610675575060015b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156106ab578181015183820152602001610693565b50506000910152565b600082601f8301126106c557600080fd5b81516001600160401b03808211156106df576106df61067a565b604051601f8301601f19908116603f011681019082821181831017156107075761070761067a565b8160405283815286602085880101111561072057600080fd5b610731846020830160208901610690565b9695505050505050565b80516001600160a01b038116811461067557600080fd5b600080600080600080600080610100898b03121561076f57600080fd5b88516001600160401b038082111561078657600080fd5b6107928c838d016106b4565b995060208b01519150808211156107a857600080fd5b506107b58b828c016106b4565b975050604089015195506107cb60608a0161073b565b94506107d960808a0161073b565b935060a089015192506107ee60c08a0161073b565b91506107fc60e08a0161073b565b90509295985092959890939650565b600181811c9082168061081f57607f821691505b60208210810361083f57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561059e576000816000526020600020601f850160051c8101602086101561086e5750805b601f850160051c820191505b8181101561088d5782815560010161087a565b505050505050565b81516001600160401b038111156108ae576108ae61067a565b6108c2816108bc845461080b565b84610845565b602080601f8311600181146108f757600084156108df5750858301515b600019600386901b1c1916600185901b17855561088d565b600085815260208120601f198616915b8281101561092657888601518255948401946001909101908401610907565b50858210156109445787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176101d4576101d4610954565b60008261099e57634e487b7160e01b600052601260045260246000fd5b500490565b60208152600082518060208401526109c2816040850160208701610690565b601f01601f19169190910160400192915050565b8051602080830151919081101561083f5760001960209190910360031b1b16919050565b818103818111156101d4576101d4610954565b808201808211156101d4576101d4610954565b600060208284031215610a3257600080fd5b5051919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e051611af4610aed60003960008181610229015261162201526000818161041b0152610e4201526000818161032801526114d801526000818161036d01526115890152600081816102d3015261153401526000610c4e01526000610c2101526000610b5201526000610b2a01526000610a8501526000610aaf01526000610ad90152611af46000f3fe608060405234801561001057600080fd5b506004361061018d5760003560e01c80637c21d5e0116100e357806395d89b411161008c578063dd62ed3e11610066578063dd62ed3e146103bd578063f2fde38b14610403578063fe4c4af41461041657600080fd5b806395d89b411461038f578063a9059cbb14610397578063d505accf146103aa57600080fd5b806389f9a1d3116100bd57806389f9a1d3146103235780638da5cb5b1461034a57806391f03efd1461036857600080fd5b80637c21d5e0146102ce5780637ecebe00146102f557806384b0196e1461030857600080fd5b8063313ce56711610145578063665a11ca1161011f578063665a11ca1461027057806370a0823114610290578063715018a6146102c657600080fd5b8063313ce5671461020d5780633644e5151461021c57806345d818431461022457600080fd5b8063095ea7b311610176578063095ea7b3146101c557806318160ddd146101e857806323b872dd146101fa57600080fd5b8063018770201461019257806306fdde03146101a7575b600080fd5b6101a56101a0366004611767565b61043d565b005b6101af6104d9565b6040516101bc91906117ed565b60405180910390f35b6101d86101d3366004611800565b61056b565b60405190151581526020016101bc565b6002545b6040519081526020016101bc565b6101d861020836600461182a565b610585565b604051601281526020016101bc565b6101ec6105a9565b61024b7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bc565b60095461024b9073ffffffffffffffffffffffffffffffffffffffff1681565b6101ec61029e366004611767565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101a56105b8565b61024b7f000000000000000000000000000000000000000000000000000000000000000081565b6101ec610303366004611767565b6105cc565b6103106105f7565b6040516101bc9796959493929190611866565b6101ec7f000000000000000000000000000000000000000000000000000000000000000081565b60085473ffffffffffffffffffffffffffffffffffffffff1661024b565b61024b7f000000000000000000000000000000000000000000000000000000000000000081565b6101af610659565b6101d86103a5366004611800565b610668565b6101a56103b8366004611928565b610676565b6101ec6103cb36600461199b565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101a5610411366004611767565b610828565b6101ec7f000000000000000000000000000000000000000000000000000000000000000081565b61044561088c565b73ffffffffffffffffffffffffffffffffffffffff8116610492576040517fc87db14b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6060600380546104e8906119ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610514906119ce565b80156105615780601f1061053657610100808354040283529160200191610561565b820191906000526020600020905b81548152906001019060200180831161054457829003601f168201915b5050505050905090565b6000336105798185856108df565b60019150505b92915050565b6000336105938582856108f1565b61059e8585856109c0565b506001949350505050565b60006105b3610a6b565b905090565b6105c061088c565b6105ca6000610ba3565b565b73ffffffffffffffffffffffffffffffffffffffff811660009081526007602052604081205461057f565b60006060806000806000606061060b610c1a565b610613610c47565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b6060600480546104e8906119ce565b6000336105798185856109c0565b834211156106b8576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024015b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886107128c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050600061077a82610c74565b9050600061078a82878787610cbc565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610811576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106af565b61081c8a8a8a6108df565b50505050505050505050565b61083061088c565b73ffffffffffffffffffffffffffffffffffffffff8116610880576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b61088981610ba3565b50565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106af565b6108ec8383836001610cea565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109ba57818110156109ab576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106af565b6109ba84848484036000610cea565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a10576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b73ffffffffffffffffffffffffffffffffffffffff8216610a60576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b6108ec838383610e32565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610ad157507f000000000000000000000000000000000000000000000000000000000000000046145b15610afb57507f000000000000000000000000000000000000000000000000000000000000000090565b6105b3604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105b37f00000000000000000000000000000000000000000000000000000000000000006005611029565b60606105b37f00000000000000000000000000000000000000000000000000000000000000006006611029565b600061057f610c81610a6b565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b600080600080610cce888888886110d4565b925092509250610cde82826111ce565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416610d3a576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b73ffffffffffffffffffffffffffffffffffffffff8316610d8a576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604080832093871683529290522082905580156109ba578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610e2491815260200190565b60405180910390a350505050565b610e3d8383836112d6565b6009547f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff16610f4b5760085473ffffffffffffffffffffffffffffffffffffffff85811691161480610ebf575060085473ffffffffffffffffffffffffffffffffffffffff8481169116145b6109ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201527f657421000000000000000000000000000000000000000000000000000000000060648201526084016106af565b80421015610f85576040517ff67ab97f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610f918242611a50565b905062015180811115610fa5575050505050565b610e1081101561100d57610fb98484611481565b610fc285611530565b8015610fd25750610fd284611530565b611008576040517f0157782000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611022565b62015180811015611022576110228484611481565b5050505050565b606060ff83146110435761103c836116c3565b905061057f565b81805461104f906119ce565b80601f016020809104026020016040519081016040528092919081815260200182805461107b906119ce565b80156110c85780601f1061109d576101008083540402835291602001916110c8565b820191906000526020600020905b8154815290600101906020018083116110ab57829003601f168201915b5050505050905061057f565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561110f57506000915060039050826111c4565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611163573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166111ba575060009250600191508290506111c4565b9250600091508190505b9450945094915050565b60008260038111156111e2576111e2611a63565b036111eb575050565b60018260038111156111ff576111ff611a63565b03611236576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561124a5761124a611a63565b03611284576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106af565b600382600381111561129857611298611a63565b036112d2576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106af565b5050565b73ffffffffffffffffffffffffffffffffffffffff831661130e5780600260008282546113039190611a92565b909155506113c09050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015611394576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106af565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff82166113e957600280548290039055611415565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161147491815260200190565b60405180910390a3505050565b60095473ffffffffffffffffffffffffffffffffffffffff8381169116146112d25773ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260408120546114d4908390611a92565b90507f00000000000000000000000000000000000000000000000000000000000000008111156108ec576040517fb7eae0d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614806115d757507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b8061169057506040517f773c02d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063773c02d490602401602060405180830381865afa158015611669573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168d9190611aa5565b15155b806116b5575060095473ffffffffffffffffffffffffffffffffffffffff8381169116145b156116be575060015b919050565b606060006116d083611702565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f81111561057f576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146116be57600080fd5b60006020828403121561177957600080fd5b61178282611743565b9392505050565b6000815180845260005b818110156117af57602081850181015186830182015201611793565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6020815260006117826020830184611789565b6000806040838503121561181357600080fd5b61181c83611743565b946020939093013593505050565b60008060006060848603121561183f57600080fd5b61184884611743565b925061185660208501611743565b9150604084013590509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e060208401526118a360e084018a611789565b83810360408501526118b5818a611789565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015611916578351835292840192918401916001016118fa565b50909c9b505050505050505050505050565b600080600080600080600060e0888a03121561194357600080fd5b61194c88611743565b965061195a60208901611743565b95506040880135945060608801359350608088013560ff8116811461197e57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156119ae57600080fd5b6119b783611743565b91506119c560208401611743565b90509250929050565b600181811c908216806119e257607f821691505b602082108103611a1b577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561057f5761057f611a21565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8082018082111561057f5761057f611a21565b600060208284031215611ab757600080fd5b505191905056fea2646970667358221220b17b5abdbfbe865c7b10d0cd3d8d491301d997d3099092e13dc054ae131d3ba264736f6c63430008190033a2646970667358221220cfecaf59466453eb1e722b40ef3302f3a9c05e69a919b17ff804634f07369b7d64736f6c63430008190033", - "deployedBytecode": "0x6080604052600436106101d85760003560e01c80636382d9ad11610102578063bdefc19011610095578063e77c7cd211610064578063e77c7cd214610622578063f0fa55a91461064f578063f2fde38b1461066f578063f984bc051461068f57600080fd5b8063bdefc19014610585578063d082e381146105b8578063d586c5f1146105ce578063d6a298e9146105ee57600080fd5b80638da5cb5b116100d15780638da5cb5b146104f15780639157742a1461051c5780639cec7a171461054f578063bd26b7951461056557600080fd5b80636382d9ad14610474578063715018a6146104945780638051a3ad146104a957806388dcaa6d146104dc57600080fd5b80633e032a3b1161017a5780635313be2c116101495780635313be2c14610401578063581c5959146102f15780635af91370146104215780635caab6be1461045457600080fd5b80633e032a3b146103475780633ebdf71f1461036b57806340f0519c1461039e57806344e35618146103e157600080fd5b80631bf01e9b116101b65780631bf01e9b1461029e5780631fef0820146102d157806331540bf3146102f1578063328f0d3a1461031c57600080fd5b80630edba8ce146101dd578063121b40b6146102365780631867937c14610258575b600080fd5b3480156101e957600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561024257600080fd5b50610256610251366004612b6f565b6106c2565b005b61026b610266366004612ce9565b6107b8565b6040805173ffffffffffffffffffffffffffffffffffffffff94851681529390921660208401529082015260600161022d565b3480156102aa57600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156102dd57600080fd5b506102566102ec366004612d84565b61149d565b3480156102fd57600080fd5b5060015473ffffffffffffffffffffffffffffffffffffffff1661020c565b34801561032857600080fd5b5060025473ffffffffffffffffffffffffffffffffffffffff1661020c565b34801561035357600080fd5b5061035d60055481565b60405190815260200161022d565b34801561037757600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156103aa57600080fd5b5061020c6103b9366004612d9f565b60009081526009602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b3480156103ed57600080fd5b5061035d6103fc366004612db8565b61154a565b34801561040d57600080fd5b5061025661041c366004612d9f565b611584565b34801561042d57600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b34801561046057600080fd5b5061025661046f366004612db8565b6115fb565b34801561048057600080fd5b5061025661048f366004612db8565b611870565b3480156104a057600080fd5b50610256611b29565b3480156104b557600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156104e857600080fd5b5060035461035d565b3480156104fd57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff1661020c565b34801561052857600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b34801561055b57600080fd5b5061035d60045481565b34801561057157600080fd5b50610256610580366004612d9f565b611b3d565b34801561059157600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b3480156105c457600080fd5b5061035d60075481565b3480156105da57600080fd5b506102566105e9366004612db8565b611bb4565b3480156105fa57600080fd5b5060065461060c9064ffffffffff1681565b60405164ffffffffff909116815260200161022d565b34801561062e57600080fd5b5061064261063d366004612b6f565b611e5f565b60405161022d9190612df1565b34801561065b57600080fd5b5061025661066a366004612d9f565b611ed8565b34801561067b57600080fd5b5061025661068a366004612b6f565b611f15565b34801561069b57600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061020c565b6106ca611f7e565b60015473ffffffffffffffffffffffffffffffffffffffff82811691161480610707575073ffffffffffffffffffffffffffffffffffffffff8116155b1561073e576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdbe246cfe804b22936a913bd3b7c4afe2ff6632dcf29b6ec8dc2fff938161e3a906020015b60405180910390a150565b60008060006004543410156107f9576040517faee4b66100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61080233611fd1565b60006108548a8a8a8a7f0000000000000000000000000000000000000000000000000000000000000000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166121bc565b6040517fc9c6539600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301527f0000000000000000000000000000000000000000000000000000000000000000811660248301529194508492507f00000000000000000000000000000000000000000000000000000000000000009182169063c9c65396906044016020604051808303816000875af1158015610912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109369190612e35565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018c90529196509083169063095ea7b3906044016020604051808303816000875af11580156109cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f39190612e52565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018b905283169063095ea7b3906044016020604051808303816000875af1158015610a69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8d9190612e52565b507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff811663f305d71934878d808330610add42610258612e9e565b60405160e089901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff9687166004820152602481019590955260448501939093526064840191909152909216608482015260a481019190915260c40160606040518083038185885af1158015610b6f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610b949190612eb1565b50506040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301527f0000000000000000000000000000000000000000000000000000000000000000811660248301528416915063e6a4390590604401602060405180830381865afa158015610c2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4f9190612e35565b955073ffffffffffffffffffffffffffffffffffffffff8616610c9e576040517fafc19a6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f0187702000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152841690630187702090602401600060405180830381600087803b158015610d0757600080fd5b505af1158015610d1b573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663715018a66040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610d6757600080fd5b505af1158015610d7b573d6000803e3d6000fd5b508892505088159050610f82576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063a9059cbb9060009083906370a0823190602401602060405180830381865afa158015610dfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e219190612edf565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af1158015610e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb59190612e52565b506040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152339073ffffffffffffffffffffffffffffffffffffffff898116917fd289537cc1c5d4ce83b387cec5cdc2658a741cf986d6ad8521af47b377be7ef6918516906370a0823190602401602060405180830381865afa158015610f48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6c9190612edf565b60405190815260200160405180910390a36113b6565b60065464ffffffffff908116908a161015610fc9576040517f25d66d2c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82169063095ea7b3907f00000000000000000000000000000000000000000000000000000000000000009083906370a0823190602401602060405180830381865afa15801561105d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110819190612edf565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af11580156110f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111159190612e52565b50611178604080516101008101825260008082526020808301829052828401829052606083018290526080830182905260a083018290528351808501855282815280820183905260c084015283518085019094528184528301529060e082015290565b308082523360208301526040517f70a08231000000000000000000000000000000000000000000000000000000008152600481019190915273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156111ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112129190612edf565b6fffffffffffffffffffffffffffffffff1660408083019190915273ffffffffffffffffffffffffffffffffffffffff8316606083015260006080830152600160a08301819052815180830190925281906112708d62015180612ef8565b61127a9190612f21565b64ffffffffff1681526020016112938c62015180612ef8565b64ffffffffff16905260c08201526040517fab167ccc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063ab167ccc90611313908490600401612f46565b6020604051808303816000875af1158015611332573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113569190612edf565b336000818152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8e168085529252808320859055519399509289917f39679ae33cd13645ec63a701454bd16e6beb24116d89b21c45edb2647cf0bd2e91a4505b6113cd60026003546113c89190613021565b61227a565b6113d56125a0565b600754604051339073ffffffffffffffffffffffffffffffffffffffff8916907f1a780177e5001bb4f067da390710f31a74a35b48fe52f49d5b60e854744f115490600090a433600081815260086020908152604080832060078054825460018101845592865284862090920191909155805484526009909252822080547fffffffffffffffffffffffff000000000000000000000000000000000000000016909317909255815491906114888361305c565b91905055505050505096509650969350505050565b6114a5611f7e565b8064ffffffffff166000036114e6576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000001664ffffffffff83169081179091556040519081527f73e38b32aad3b3e0d429bc819e2d79b4712f86c083bacf669d22ab304fe5888d906020016107ad565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152600a60209081526040808320938616835292905220545b92915050565b61158c611f7e565b806000036115c6576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60038190556040518181527fc799be5eb19a1a6d6ba7368d21e2bc367c8a335e4a07cd3d954482e6f714d3c5906020016107ad565b336000908152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915290205480158061164d575073ffffffffffffffffffffffffffffffffffffffff8216155b8061170457506040517fb2564569000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063b256456990602401602060405180830381865afa1580156116de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117029190612e52565b155b1561173b576040517f686ad40700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8281166000818152600a60208181526040808420898716808652908352818520889055338086529383528185209085529091528083209290925590517f23b872dd00000000000000000000000000000000000000000000000000000000815260048101919091526024810191909152604481018390527f0000000000000000000000000000000000000000000000000000000000000000909116906323b872dd90606401600060405180830381600087803b15801561180e57600080fd5b505af1158015611822573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff8086169350861691507f41f8af339a1fd0d4ed41d2aec5c89989b96536e24958255ed584080bb2c1623190600090a3505050565b611878611f7e565b73ffffffffffffffffffffffffffffffffffffffff811615806118af575073ffffffffffffffffffffffffffffffffffffffff8216155b156118e6576040517fafc19a6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829060009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015611955573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119799190612edf565b9050806000036119b5576040517f9f4ef32900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af1158015611a2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4e9190612e52565b506040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff80851691908416906370a0823190602401602060405180830381865afa158015611abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae29190612edf565b60405173ffffffffffffffffffffffffffffffffffffffff8716907faaeda929aa102e867049528ec7cd2499e3a2f8846e736ae7935f234dfbf500d990600090a450505050565b611b31611f7e565b611b3b6000612aab565b565b611b45611f7e565b80600003611b7f576040517fa6d5c7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60048190556040518181527f1fd55d90af4abf6458d9caa4afe3590d7a8ea749b373a53114a7273fe7c8b631906020016107ad565b73ffffffffffffffffffffffffffffffffffffffff8116611c01576040517fafc19a6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000908152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205490819003611c6c576040517f686ad40700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fd975dfed000000000000000000000000000000000000000000000000000000008152600481018290526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063d975dfed90602401602060405180830381865afa158015611cfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1e91906130b4565b6fffffffffffffffffffffffffffffffff16905080600003611d6c576040517f21b34bd500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fea5ead190000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff84811660248301527f0000000000000000000000000000000000000000000000000000000000000000169063ea5ead1990604401600060405180830381600087803b158015611dfc57600080fd5b505af1158015611e10573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff8087169350871691507ff58c2894662c00ada7f78292cc1d18f7de0ff41bf57e6bcb13e7cda455d8a59090600090a350505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260086020908152604091829020805483518184028101840190945280845260609392830182828015611ecc57602002820191906000526020600020905b815481526020019060010190808311611eb8575b50505050509050919050565b611ee0611f7e565b60058190556040518181527ff5a802650e0a86db227cc342f06327d2ca0ff5cf2b12e0084fc5d8a7db2c54fd906020016107ad565b611f1d611f7e565b73ffffffffffffffffffffffffffffffffffffffff8116611f72576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b611f7b81612aab565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314611b3b576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611f69565b6003546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f00000000000000000000000000000000000000000000000000000000000000009291908316906370a0823190602401602060405180830381865afa158015612064573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120889190612edf565b10156120c0576040517f9f4ef32900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015230602483015260448201929092526000918316906323b872dd906064016020604051808303816000875af1158015612142573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121669190612e52565b9050806121b7576040517f61fa4c0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401611f69565b505050565b60008415806121d657506121d3426202a300612e9e565b84105b1561220d576040517fcff90ad900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8686867f00000000000000000000000000000000000000000000000000000000000000003088888860405161224190612b40565b612252989796959493929190613133565b604051809103906000f08015801561226e573d6000803e3d6000fd5b50979650505050505050565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303816000875af115801561232f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123539190612e52565b506040517f4c09cf4e0000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660248301527f000000000000000000000000000000000000000000000000000000000000000081166044830152600160648301526000917f000000000000000000000000000000000000000000000000000000000000000090911690634c09cf4e90608401600060405180830381865afa15801561243b573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526124819190810190613244565b90506124ae6040518060800160405280600081526020016000815260200160608152602001606081525090565b828152815180516124c190600190613359565b815181106124d1576124d161336c565b6020908102919091018101518282015260408084015181840152908301516060830152517f6bf2df8600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690636bf2df869061256990849030906000906004016133ed565b600060405180830381600087803b15801561258357600080fd5b505af1158015612597573d6000803e3d6000fd5b50505050505050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa15801561262d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126519190612edf565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156126e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127059190612edf565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018590529192507f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af11580156127bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e39190612e52565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303816000875af1158015612899573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128bd9190612e52565b5060006040518061016001604052807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1681526020017f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168152602001610bb862ffffff1681526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c60020b8152602001620d89b460020b815260200183815260200184815260200161299e84600554612b20565b6129a89085613359565b81526020016129b985600554612b20565b6129c39086613359565b815260025473ffffffffffffffffffffffffffffffffffffffff1660208201526040016129f1426078612e9e565b90526040517f8831645600000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690638831645690612a68908490600401613482565b6080604051808303816000875af1158015612a87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612597919061356d565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000612710612b2f83856135a9565b612b399190613021565b9392505050565b6125e1806135c183390190565b73ffffffffffffffffffffffffffffffffffffffff81168114611f7b57600080fd5b600060208284031215612b8157600080fd5b8135612b3981612b4d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715612bde57612bde612b8c565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715612c2b57612c2b612b8c565b604052919050565b600082601f830112612c4457600080fd5b813567ffffffffffffffff811115612c5e57612c5e612b8c565b612c8f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612be4565b818152846020838601011115612ca457600080fd5b816020850160208301376000918101602001919091529392505050565b803564ffffffffff81168114612cd657600080fd5b919050565b8015158114611f7b57600080fd5b60008060008060008060c08789031215612d0257600080fd5b863567ffffffffffffffff80821115612d1a57600080fd5b612d268a838b01612c33565b97506020890135915080821115612d3c57600080fd5b50612d4989828a01612c33565b9550506040870135935060608701359250612d6660808801612cc1565b915060a0870135612d7681612cdb565b809150509295509295509295565b600060208284031215612d9657600080fd5b612b3982612cc1565b600060208284031215612db157600080fd5b5035919050565b60008060408385031215612dcb57600080fd5b8235612dd681612b4d565b91506020830135612de681612b4d565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b81811015612e2957835183529284019291840191600101612e0d565b50909695505050505050565b600060208284031215612e4757600080fd5b8151612b3981612b4d565b600060208284031215612e6457600080fd5b8151612b3981612cdb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561157e5761157e612e6f565b600080600060608486031215612ec657600080fd5b8351925060208401519150604084015190509250925092565b600060208284031215612ef157600080fd5b5051919050565b64ffffffffff818116838216028082169190828114612f1957612f19612e6f565b505092915050565b64ffffffffff828116828216039080821115612f3f57612f3f612e6f565b5092915050565b60006101408201905073ffffffffffffffffffffffffffffffffffffffff8084511683528060208501511660208401526fffffffffffffffffffffffffffffffff6040850151166040840152806060850151166060840152506080830151612fb2608084018215159052565b5060a0830151612fc660a084018215159052565b5060c0830151612fed60c0840182805164ffffffffff908116835260209182015116910152565b5060e0830151805173ffffffffffffffffffffffffffffffffffffffff166101008401526020810151610120840152612f3f565b600082613057577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361308d5761308d612e6f565b5060010190565b80516fffffffffffffffffffffffffffffffff81168114612cd657600080fd5b6000602082840312156130c657600080fd5b612b3982613094565b6000815180845260005b818110156130f5576020818501810151868301820152016130d9565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b60006101008083526131478184018c6130cf565b9050828103602084015261315b818b6130cf565b6040840199909952505073ffffffffffffffffffffffffffffffffffffffff9586166060820152938516608085015260a0840192909252831660c083015290911660e09091015292915050565b600067ffffffffffffffff8211156131c2576131c2612b8c565b5060051b60200190565b600082601f8301126131dd57600080fd5b815160206131f26131ed836131a8565b612be4565b8083825260208201915060208460051b87010193508684111561321457600080fd5b602086015b8481101561323957805161322c81612b4d565b8352918301918301613219565b509695505050505050565b6000602080838503121561325757600080fd5b825167ffffffffffffffff8082111561326f57600080fd5b908401906080828703121561328357600080fd5b61328b612bbb565b82518281111561329a57600080fd5b8301601f810188136132ab57600080fd5b80516132b96131ed826131a8565b81815260059190911b8201860190868101908a8311156132d857600080fd5b928701925b828410156132f6578351825292870192908701906132dd565b8452505050828401518281111561330c57600080fd5b613318888286016131cc565b8583015250604083015193508184111561333157600080fd5b61333d878585016131cc565b6040820152606083015160608201528094505050505092915050565b8181038181111561157e5761157e612e6f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008151808452602080850194506020840160005b838110156133e257815173ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016133b0565b509495945050505050565b60608152835160608201526020840151608082015260006040850151608060a084015261341d60e084018261339b565b905060608601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08483030160c0850152613458828261339b565b73ffffffffffffffffffffffffffffffffffffffff96909616602085015250505060400152919050565b815173ffffffffffffffffffffffffffffffffffffffff168152610160810160208301516134c8602084018273ffffffffffffffffffffffffffffffffffffffff169052565b5060408301516134df604084018262ffffff169052565b5060608301516134f4606084018260020b9052565b506080830151613509608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e08301526101008084015181840152506101208084015161355c8285018273ffffffffffffffffffffffffffffffffffffffff169052565b505061014092830151919092015290565b6000806000806080858703121561358357600080fd5b8451935061359360208601613094565b6040860151606090960151949790965092505050565b808202811582820484141761157e5761157e612e6f56fe61020060405234801561001157600080fd5b506040516125e13803806125e183398101604081905261003091610752565b838880604051806040016040528060018152602001603160f81b8152508b8b816003908161005e9190610895565b50600461006b8282610895565b5061007b915083905060056101a7565b6101205261008a8160066101a7565b61014052815160208084019190912060e052815190820120610100524660a05261011760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506001600160a01b03811661015057604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610159816101da565b506001600160a01b0385166101e052610172338761022c565b61017d866064610266565b6101a0526101c0929092526001600160a01b0390811661016052166101805250610a399350505050565b60006020835110156101c3576101bc83610286565b90506101d4565b816101ce8482610895565b5060ff90505b92915050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166102565760405163ec442f0560e01b815260006004820152602401610147565b610262600083836102c4565b5050565b6000612710610275838561096a565b61027f9190610981565b9392505050565b600080829050601f815111156102b1578260405163305a27a960e01b815260040161014791906109a3565b80516102bc826109d6565b179392505050565b6102cf838383610415565b6101c0516009546001600160a01b031661036a576008546001600160a01b038581169116148061030c57506008546001600160a01b038481169116145b6103645760405162461bcd60e51b815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201526265742160e81b6064820152608401610147565b50505050565b8042101561038b5760405163f67ab97f60e01b815260040160405180910390fd5b600061039782426109fa565b9050620151808111156103ab575050505050565b610e108110156103f9576103bf848461053f565b6103c8856105a3565b80156103d857506103d8846105a3565b6103f457604051620abbc160e51b815260040160405180910390fd5b61040e565b6201518081101561040e5761040e848461053f565b5050505050565b6001600160a01b0383166104405780600260008282546104359190610a0d565b909155506104b29050565b6001600160a01b038316600090815260208190526040902054818110156104935760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610147565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166104ce576002805482900390556104ed565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161053291815260200190565b60405180910390a3505050565b6009546001600160a01b03838116911614610262576001600160a01b038216600090815260208190526040812054610578908390610a0d565b90506101a05181111561059e5760405163b7eae0d360e01b815260040160405180910390fd5b505050565b6000610160516001600160a01b0316826001600160a01b031614806105dc5750610180516001600160a01b0316826001600160a01b0316145b8061065457506101e051604051631dcf00b560e21b81526001600160a01b0384811660048301529091169063773c02d490602401602060405180830381865afa15801561062d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106519190610a20565b15155b8061066c57506009546001600160a01b038381169116145b15610675575060015b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156106ab578181015183820152602001610693565b50506000910152565b600082601f8301126106c557600080fd5b81516001600160401b03808211156106df576106df61067a565b604051601f8301601f19908116603f011681019082821181831017156107075761070761067a565b8160405283815286602085880101111561072057600080fd5b610731846020830160208901610690565b9695505050505050565b80516001600160a01b038116811461067557600080fd5b600080600080600080600080610100898b03121561076f57600080fd5b88516001600160401b038082111561078657600080fd5b6107928c838d016106b4565b995060208b01519150808211156107a857600080fd5b506107b58b828c016106b4565b975050604089015195506107cb60608a0161073b565b94506107d960808a0161073b565b935060a089015192506107ee60c08a0161073b565b91506107fc60e08a0161073b565b90509295985092959890939650565b600181811c9082168061081f57607f821691505b60208210810361083f57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561059e576000816000526020600020601f850160051c8101602086101561086e5750805b601f850160051c820191505b8181101561088d5782815560010161087a565b505050505050565b81516001600160401b038111156108ae576108ae61067a565b6108c2816108bc845461080b565b84610845565b602080601f8311600181146108f757600084156108df5750858301515b600019600386901b1c1916600185901b17855561088d565b600085815260208120601f198616915b8281101561092657888601518255948401946001909101908401610907565b50858210156109445787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176101d4576101d4610954565b60008261099e57634e487b7160e01b600052601260045260246000fd5b500490565b60208152600082518060208401526109c2816040850160208701610690565b601f01601f19169190910160400192915050565b8051602080830151919081101561083f5760001960209190910360031b1b16919050565b818103818111156101d4576101d4610954565b808201808211156101d4576101d4610954565b600060208284031215610a3257600080fd5b5051919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e051611af4610aed60003960008181610229015261162201526000818161041b0152610e4201526000818161032801526114d801526000818161036d01526115890152600081816102d3015261153401526000610c4e01526000610c2101526000610b5201526000610b2a01526000610a8501526000610aaf01526000610ad90152611af46000f3fe608060405234801561001057600080fd5b506004361061018d5760003560e01c80637c21d5e0116100e357806395d89b411161008c578063dd62ed3e11610066578063dd62ed3e146103bd578063f2fde38b14610403578063fe4c4af41461041657600080fd5b806395d89b411461038f578063a9059cbb14610397578063d505accf146103aa57600080fd5b806389f9a1d3116100bd57806389f9a1d3146103235780638da5cb5b1461034a57806391f03efd1461036857600080fd5b80637c21d5e0146102ce5780637ecebe00146102f557806384b0196e1461030857600080fd5b8063313ce56711610145578063665a11ca1161011f578063665a11ca1461027057806370a0823114610290578063715018a6146102c657600080fd5b8063313ce5671461020d5780633644e5151461021c57806345d818431461022457600080fd5b8063095ea7b311610176578063095ea7b3146101c557806318160ddd146101e857806323b872dd146101fa57600080fd5b8063018770201461019257806306fdde03146101a7575b600080fd5b6101a56101a0366004611767565b61043d565b005b6101af6104d9565b6040516101bc91906117ed565b60405180910390f35b6101d86101d3366004611800565b61056b565b60405190151581526020016101bc565b6002545b6040519081526020016101bc565b6101d861020836600461182a565b610585565b604051601281526020016101bc565b6101ec6105a9565b61024b7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bc565b60095461024b9073ffffffffffffffffffffffffffffffffffffffff1681565b6101ec61029e366004611767565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101a56105b8565b61024b7f000000000000000000000000000000000000000000000000000000000000000081565b6101ec610303366004611767565b6105cc565b6103106105f7565b6040516101bc9796959493929190611866565b6101ec7f000000000000000000000000000000000000000000000000000000000000000081565b60085473ffffffffffffffffffffffffffffffffffffffff1661024b565b61024b7f000000000000000000000000000000000000000000000000000000000000000081565b6101af610659565b6101d86103a5366004611800565b610668565b6101a56103b8366004611928565b610676565b6101ec6103cb36600461199b565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101a5610411366004611767565b610828565b6101ec7f000000000000000000000000000000000000000000000000000000000000000081565b61044561088c565b73ffffffffffffffffffffffffffffffffffffffff8116610492576040517fc87db14b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6060600380546104e8906119ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610514906119ce565b80156105615780601f1061053657610100808354040283529160200191610561565b820191906000526020600020905b81548152906001019060200180831161054457829003601f168201915b5050505050905090565b6000336105798185856108df565b60019150505b92915050565b6000336105938582856108f1565b61059e8585856109c0565b506001949350505050565b60006105b3610a6b565b905090565b6105c061088c565b6105ca6000610ba3565b565b73ffffffffffffffffffffffffffffffffffffffff811660009081526007602052604081205461057f565b60006060806000806000606061060b610c1a565b610613610c47565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b6060600480546104e8906119ce565b6000336105798185856109c0565b834211156106b8576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024015b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886107128c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050600061077a82610c74565b9050600061078a82878787610cbc565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610811576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106af565b61081c8a8a8a6108df565b50505050505050505050565b61083061088c565b73ffffffffffffffffffffffffffffffffffffffff8116610880576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b61088981610ba3565b50565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106af565b6108ec8383836001610cea565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109ba57818110156109ab576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106af565b6109ba84848484036000610cea565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a10576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b73ffffffffffffffffffffffffffffffffffffffff8216610a60576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b6108ec838383610e32565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610ad157507f000000000000000000000000000000000000000000000000000000000000000046145b15610afb57507f000000000000000000000000000000000000000000000000000000000000000090565b6105b3604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105b37f00000000000000000000000000000000000000000000000000000000000000006005611029565b60606105b37f00000000000000000000000000000000000000000000000000000000000000006006611029565b600061057f610c81610a6b565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b600080600080610cce888888886110d4565b925092509250610cde82826111ce565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416610d3a576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b73ffffffffffffffffffffffffffffffffffffffff8316610d8a576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106af565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604080832093871683529290522082905580156109ba578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610e2491815260200190565b60405180910390a350505050565b610e3d8383836112d6565b6009547f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff16610f4b5760085473ffffffffffffffffffffffffffffffffffffffff85811691161480610ebf575060085473ffffffffffffffffffffffffffffffffffffffff8481169116145b6109ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f50617469656e6365202d2054726164696e67204e6f742053746172746564205960448201527f657421000000000000000000000000000000000000000000000000000000000060648201526084016106af565b80421015610f85576040517ff67ab97f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610f918242611a50565b905062015180811115610fa5575050505050565b610e1081101561100d57610fb98484611481565b610fc285611530565b8015610fd25750610fd284611530565b611008576040517f0157782000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611022565b62015180811015611022576110228484611481565b5050505050565b606060ff83146110435761103c836116c3565b905061057f565b81805461104f906119ce565b80601f016020809104026020016040519081016040528092919081815260200182805461107b906119ce565b80156110c85780601f1061109d576101008083540402835291602001916110c8565b820191906000526020600020905b8154815290600101906020018083116110ab57829003601f168201915b5050505050905061057f565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561110f57506000915060039050826111c4565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611163573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166111ba575060009250600191508290506111c4565b9250600091508190505b9450945094915050565b60008260038111156111e2576111e2611a63565b036111eb575050565b60018260038111156111ff576111ff611a63565b03611236576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561124a5761124a611a63565b03611284576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106af565b600382600381111561129857611298611a63565b036112d2576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106af565b5050565b73ffffffffffffffffffffffffffffffffffffffff831661130e5780600260008282546113039190611a92565b909155506113c09050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015611394576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106af565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff82166113e957600280548290039055611415565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161147491815260200190565b60405180910390a3505050565b60095473ffffffffffffffffffffffffffffffffffffffff8381169116146112d25773ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260408120546114d4908390611a92565b90507f00000000000000000000000000000000000000000000000000000000000000008111156108ec576040517fb7eae0d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614806115d757507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b8061169057506040517f773c02d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063773c02d490602401602060405180830381865afa158015611669573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168d9190611aa5565b15155b806116b5575060095473ffffffffffffffffffffffffffffffffffffffff8381169116145b156116be575060015b919050565b606060006116d083611702565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f81111561057f576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146116be57600080fd5b60006020828403121561177957600080fd5b61178282611743565b9392505050565b6000815180845260005b818110156117af57602081850181015186830182015201611793565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6020815260006117826020830184611789565b6000806040838503121561181357600080fd5b61181c83611743565b946020939093013593505050565b60008060006060848603121561183f57600080fd5b61184884611743565b925061185660208501611743565b9150604084013590509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e060208401526118a360e084018a611789565b83810360408501526118b5818a611789565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015611916578351835292840192918401916001016118fa565b50909c9b505050505050505050505050565b600080600080600080600060e0888a03121561194357600080fd5b61194c88611743565b965061195a60208901611743565b95506040880135945060608801359350608088013560ff8116811461197e57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156119ae57600080fd5b6119b783611743565b91506119c560208401611743565b90509250929050565b600181811c908216806119e257607f821691505b602082108103611a1b577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561057f5761057f611a21565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8082018082111561057f5761057f611a21565b600060208284031215611ab757600080fd5b505191905056fea2646970667358221220b17b5abdbfbe865c7b10d0cd3d8d491301d997d3099092e13dc054ae131d3ba264736f6c63430008190033a2646970667358221220cfecaf59466453eb1e722b40ef3302f3a9c05e69a919b17ff804634f07369b7d64736f6c63430008190033", - "devdoc": { - "author": "Roy & Jose", - "details": "Utilizes 'Sablier' for liquidity locking", - "errors": { - "OwnableInvalidOwner(address)": [ - { - "details": "The owner is not a valid owner account. (eg. `address(0)`)" - } - ], - "OwnableUnauthorizedAccount(address)": [ - { - "details": "The caller account is not authorized to perform an operation." - } - ] - }, - "kind": "dev", - "methods": { - "emergencyWithdraw(address,address)": { - "details": "Withdraws any stuck tokens (LP Or USDC) to the specified address.", - "params": { - "_to": "Address to which the tokens are withdrawn.", - "_token": "Address of the token to be withdrawn." - } - }, - "getLaunchFee()": { - "details": "Returns the launch fee.", - "returns": { - "_0": "uint256 The launch fee." - } - }, - "getLiquidityLock(address,address)": { - "details": "Returns the liquidity lock for the specified pair and owner.", - "params": { - "_owner": "Address of the owner.", - "_pair": "Address of the token pair." - }, - "returns": { - "_0": "uint256 Stream ID for the liquidity lock." - } - }, - "getNonFungiblePositionManager()": { - "details": "Returns the address of the NonFungiblePositionManager contract.", - "returns": { - "_0": "address The address of the NonFungiblePositionManager contract." - } - }, - "getSablier()": { - "details": "Returns the address of the Sablier contract.", - "returns": { - "_0": "address The address of the Sablier contract." - } - }, - "getStratosphere()": { - "details": "Returns the address of the Stratosphere contract.", - "returns": { - "_0": "address The address of the Stratosphere contract." - } - }, - "getTeamMultisig()": { - "details": "Returns the address of the team multisig wallet.", - "returns": { - "_0": "address The address of the team multisig wallet." - } - }, - "getUSDC()": { - "details": "Returns the address of the USDC token.", - "returns": { - "_0": "address The address of the USDC token." - } - }, - "getVAPE()": { - "details": "Returns the address of the VAPE token.", - "returns": { - "_0": "address The address of the VAPE token." - } - }, - "getVaporDEXAdapter()": { - "details": "Returns the address of the VaporDEX adapter.", - "returns": { - "_0": "address The address of the VaporDEX adapter." - } - }, - "getVaporDEXFactory()": { - "details": "Returns the address of the VaporDEX factory.", - "returns": { - "_0": "address The address of the VaporDEX factory." - } - }, - "getVaporDEXRouter()": { - "details": "Returns the address of the VaporDEX router.", - "returns": { - "_0": "address The address of the VaporDEX router." - } - }, - "getVaporDexAdapter()": { - "details": "Returns the address of the VaporDEX adapter.", - "returns": { - "_0": "address The address of the VaporDEX adapter." - } - }, - "getVaporDexAggregator()": { - "details": "Returns the address of the VaporDEX aggregator.", - "returns": { - "_0": "address The address of the VaporDEX aggregator." - } - }, - "launch(string,string,uint256,uint256,uint40,bool)": { - "details": "Launches a new token with specified parameters.", - "params": { - "_burnLiquidity": "Flag indicating whether to burn liquidity or lock it.", - "_name": "Name of the token.", - "_symbol": "Symbol of the token.", - "_totalSupply": "Total supply of the token.", - "_tradingStartsAt": "Timestamp when trading starts for the token.", - "lockDuration": "Number of days to lock liquidity for." - }, - "returns": { - "_pair": "Address of the created token pair.", - "_tokenAddress": "Address of the launched token.", - "streamId": "Stream ID if liquidity is locked, otherwise 0." - } - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "renounceOwnership()": { - "details": "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." - }, - "setLaunchFee(uint256)": { - "details": "Sets the launch fee for creating new tokens.", - "params": { - "_launchFee": "New launch fee in USDC." - } - }, - "setMinLockDuration(uint40)": { - "details": "Sets the minimum liquidity for creating new tokens.", - "params": { - "_lockDuration": "New lock duration in days." - } - }, - "setMinimumLiquidityETH(uint256)": { - "details": "Sets the minimum liquidity for creating new tokens.", - "params": { - "_liquidity": "New liquidity." - } - }, - "setSlippage(uint256)": { - "details": "Sets the minimum liquidity for creating new tokens.", - "params": { - "_slippage": "New lock duration in days." - } - }, - "setVaporDEXAdapter(address)": { - "details": "Sets the VaporDEX adapter address.", - "params": { - "_vaporDexAdapter": "New VaporDEX adapter address." - } - }, - "transferLock(address,address)": { - "details": "Transfers the locked liquidity to the specified recipient for the given pair.", - "params": { - "_pair": "Address of the token pair.", - "_to": "Address of the recipient." - } - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "unlockLiquidityTokens(address,address)": { - "details": "Unlocks liquidity tokens for the specified pair and recipient.", - "params": { - "_pair": "Address of the token pair.", - "_receiver": "Address of the recipient of unlocked tokens." - } - } - }, - "title": "TokenFactory", - "version": 1 - }, - "userdoc": { - "events": { - "TokenLaunched(address,address,uint256)": { - "notice": "EVENTS ///" - } - }, - "kind": "user", - "methods": { - "unlockLiquidityTokens(address,address)": { - "notice": "It is recommended to direct the user to Sablier UI for better error handling." - } - }, - "notice": "This contract is used to launch new tokens and create liquidity for them", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 8, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "_owner", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 11882, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "vaporDexAdapter", - "offset": 0, - "slot": "1", - "type": "t_address" - }, - { - "astId": 11884, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "teamMultisig", - "offset": 0, - "slot": "2", - "type": "t_address" - }, - { - "astId": 11886, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "launchFee", - "offset": 0, - "slot": "3", - "type": "t_uint256" - }, - { - "astId": 11888, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "minLiquidityETH", - "offset": 0, - "slot": "4", - "type": "t_uint256" - }, - { - "astId": 11890, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "slippage", - "offset": 0, - "slot": "5", - "type": "t_uint256" - }, - { - "astId": 11892, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "minLockDuration", - "offset": 0, - "slot": "6", - "type": "t_uint40" - }, - { - "astId": 11894, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "tokenCounter", - "offset": 0, - "slot": "7", - "type": "t_uint256" - }, - { - "astId": 11899, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "addressToCounters", - "offset": 0, - "slot": "8", - "type": "t_mapping(t_address,t_array(t_uint256)dyn_storage)" - }, - { - "astId": 11903, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "counterToAddress", - "offset": 0, - "slot": "9", - "type": "t_mapping(t_uint256,t_address)" - }, - { - "astId": 11912, - "contract": "contracts/TokenFactory.sol:TokenFactory", - "label": "liquidityLocks", - "offset": 0, - "slot": "10", - "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_uint256)dyn_storage": { - "base": "t_uint256", - "encoding": "dynamic_array", - "label": "uint256[]", - "numberOfBytes": "32" - }, - "t_mapping(t_address,t_array(t_uint256)dyn_storage)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256[])", - "numberOfBytes": "32", - "value": "t_array(t_uint256)dyn_storage" - }, - "t_mapping(t_address,t_mapping(t_address,t_uint256))": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => mapping(address => uint256))", - "numberOfBytes": "32", - "value": "t_mapping(t_address,t_uint256)" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_uint256,t_address)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => address)", - "numberOfBytes": "32", - "value": "t_address" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - }, - "t_uint40": { - "encoding": "inplace", - "label": "uint40", - "numberOfBytes": "5" - } - } - } -} \ No newline at end of file diff --git a/deployments/avalancheFuji/solcInputs/0c06dec9bc6a8c34470ee6e25500a394.json b/deployments/avalancheFuji/solcInputs/0c06dec9bc6a8c34470ee6e25500a394.json deleted file mode 100644 index ac2e3ea..0000000 --- a/deployments/avalancheFuji/solcInputs/0c06dec9bc6a8c34470ee6e25500a394.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" - }, - "@openzeppelin/contracts/interfaces/IERC5267.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256))\n private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(\n address owner,\n address spender\n ) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(\n address spender,\n uint256 value\n ) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(\n address owner,\n address spender,\n uint256 value,\n bool emitEvent\n ) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 value\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(\n spender,\n currentAllowance,\n value\n );\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n bytes32 private constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Permit deadline has expired.\n */\n error ERC2612ExpiredSignature(uint256 deadline);\n\n /**\n * @dev Mismatched signature.\n */\n error ERC2612InvalidSigner(address signer, address owner);\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @inheritdoc IERC20Permit\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > deadline) {\n revert ERC2612ExpiredSignature(deadline);\n }\n\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n if (signer != owner) {\n revert ERC2612InvalidSigner(signer, owner);\n }\n\n _approve(owner, spender, value);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n return super.nonces(owner);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparatorV4();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n * {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the address zero.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Nonces.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/ShortStrings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" - }, - "@prb/math/src/Common.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" - }, - "@prb/math/src/sd1x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd1x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n" - }, - "@prb/math/src/sd1x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" - }, - "@prb/math/src/sd1x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" - }, - "@prb/math/src/sd59x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd59x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" - }, - "@prb/math/src/sd59x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" - }, - "@prb/math/src/sd59x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/sd59x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" - }, - "@prb/math/src/sd59x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" - }, - "@prb/math/src/UD2x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud2x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud2x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n" - }, - "@prb/math/src/ud2x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" - }, - "@prb/math/src/ud2x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" - }, - "@prb/math/src/UD60x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud60x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud60x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" - }, - "@prb/math/src/ud60x18/Conversions.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" - }, - "@prb/math/src/ud60x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" - }, - "@prb/math/src/ud60x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/ud60x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" - }, - "@prb/math/src/ud60x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" - }, - "@sablier/v2-core/src/interfaces/IAdminable.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Base.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\nimport { ISablierV2Comptroller } from \"./ISablierV2Comptroller.sol\";\n\n/// @title ISablierV2Base\n/// @notice Base logic for all Sablier V2 streaming contracts.\ninterface ISablierV2Base is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin claims all protocol revenues accrued for a particular ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the protocol revenues have been claimed for.\n /// @param protocolRevenues The amount of protocol revenues claimed, denoted in units of the asset's decimals.\n event ClaimProtocolRevenues(address indexed admin, IERC20 indexed asset, uint128 protocolRevenues);\n\n /// @notice Emitted when the admin sets a new comptroller contract.\n /// @param admin The address of the contract admin.\n /// @param oldComptroller The address of the old comptroller contract.\n /// @param newComptroller The address of the new comptroller contract.\n event SetComptroller(\n address indexed admin, ISablierV2Comptroller oldComptroller, ISablierV2Comptroller newComptroller\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the maximum fee that can be charged by the protocol or a broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_FEE() external view returns (UD60x18);\n\n /// @notice Retrieves the address of the comptroller contract, responsible for the Sablier V2 protocol\n /// configuration.\n function comptroller() external view returns (ISablierV2Comptroller);\n\n /// @notice Retrieves the protocol revenues accrued for the provided ERC-20 asset, in units of the asset's\n /// decimals.\n /// @param asset The contract address of the ERC-20 asset to query.\n function protocolRevenues(IERC20 asset) external view returns (uint128 revenues);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Claims all accumulated protocol revenues for the provided ERC-20 asset.\n ///\n /// @dev Emits a {ClaimProtocolRevenues} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset for which to claim protocol revenues.\n function claimProtocolRevenues(IERC20 asset) external;\n\n /// @notice Assigns a new comptroller contract responsible for the protocol configuration.\n ///\n /// @dev Emits a {SetComptroller} event.\n ///\n /// Notes:\n /// - Does not revert if the comptroller is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newComptroller The address of the new comptroller contract.\n function setComptroller(ISablierV2Comptroller newComptroller) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Comptroller.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\n\n/// @title ISablierV2Controller\n/// @notice This contract is in charge of the Sablier V2 protocol configuration, handling such values as the\n/// protocol fees.\ninterface ISablierV2Comptroller is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin sets a new flash fee.\n /// @param admin The address of the contract admin.\n /// @param oldFlashFee The old flash fee, denoted as a fixed-point number.\n /// @param newFlashFee The new flash fee, denoted as a fixed-point number.\n event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);\n\n /// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.\n /// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.\n event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);\n\n /// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset to toggle.\n /// @param newFlag Whether the ERC-20 asset can be flash loaned.\n event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.\n ///\n /// @dev Notes:\n /// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},\n /// which calculates the fee amount for a specified flash loan amount.\n /// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.\n function flashFee() external view returns (UD60x18 fee);\n\n /// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.\n /// @param token The contract address of the ERC-20 asset to check.\n function isFlashAsset(IERC20 token) external view returns (bool result);\n\n /// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.\n /// @param asset The contract address of the ERC-20 asset to query.\n /// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.\n function protocolFees(IERC20 asset) external view returns (UD60x18 fee);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.\n ///\n /// @dev Emits a {SetFlashFee} event.\n ///\n /// Notes:\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.\n function setFlashFee(UD60x18 newFlashFee) external;\n\n /// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.\n ///\n /// @dev Emits a {SetProtocolFee} event.\n ///\n /// Notes:\n /// - The fee is not denoted in units of the asset's decimals; it is a fixed-point number. Refer to the\n /// PRBMath documentation for more detail on the logic of UD60x18.\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset to update the fee for.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.\n function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;\n\n /// @notice Toggles the flash loanability of an ERC-20 asset.\n ///\n /// @dev Emits a {ToggleFlashAsset} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the admin.\n ///\n /// @param asset The address of the ERC-20 asset to toggle.\n function toggleFlashAsset(IERC20 asset) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Lockup.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\nimport { Lockup } from \"../types/DataTypes.sol\";\nimport { ISablierV2Base } from \"./ISablierV2Base.sol\";\nimport { ISablierV2NFTDescriptor } from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup streaming contracts.\ninterface ISablierV2Lockup is\n ISablierV2Base, // 1 inherited component\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The id of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The id of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The id of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset used for streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getEndTime(uint256 streamId) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream id for the query.\n function getRecipient(uint256 streamId) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStartTime(uint256 streamId) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isTransferable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Counter for stream ids, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @param streamId The stream id for the query.\n function statusOf(uint256 streamId) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The id of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The id of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The ids of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The id of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract\n /// and `msg.sender` is either the sender or an approved operator.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `msg.sender` must be the stream's sender, the stream's recipient or an approved third party.\n /// - `to` must be the recipient if `msg.sender` is the stream's sender.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n function withdrawMax(uint256 streamId, address to) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The id of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n function withdrawMaxAndTransfer(uint256 streamId, address newRecipient) external;\n\n /// @notice Withdraws assets from streams to the provided address `to`.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - All requirements from {withdraw} must be met for each stream.\n /// - There must be an equal number of `streamIds` and `amounts`.\n ///\n /// @param streamIds The ids of the streams to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport { Lockup, LockupLinear } from \"../types/DataTypes.sol\";\nimport { ISablierV2Lockup } from \"./ISablierV2Lockup.sol\";\n\n/// @title ISablierV2LockupLinear\n/// @notice Creates and manages Lockup streams with linear streaming functions.\ninterface ISablierV2LockupLinear is ISablierV2Lockup {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is created.\n /// @param streamId The id of the newly created stream.\n /// @param funder The address which funded the stream.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param recipient The address receiving the assets.\n /// @param amounts Struct containing (i) the deposit amount, (ii) the protocol fee amount, and (iii) the\n /// broker fee amount, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Boolean indicating whether the stream will be cancelable or not.\n /// @param transferable Boolean indicating whether the stream NFT is transferable or not.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker The address of the broker who has helped create the stream, e.g. a front-end website.\n event CreateLockupLinearStream(\n uint256 streamId,\n address funder,\n address indexed sender,\n address indexed recipient,\n Lockup.CreateAmounts amounts,\n IERC20 indexed asset,\n bool cancelable,\n bool transferable,\n LockupLinear.Range range,\n address broker\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the stream's cliff time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);\n\n /// @notice Retrieves the stream's range, which is a struct containing (i) the stream's start time, (ii) cliff\n /// time, and (iii) end time, all as Unix timestamps.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);\n\n /// @notice Retrieves the stream entity.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n ///\n /// When the stream is warm, the streaming function is:\n ///\n /// $$\n /// f(x) = x * d + c\n /// $$\n ///\n /// Where:\n ///\n /// - $x$ is the elapsed time divided by the stream's total duration.\n /// - $d$ is the deposited amount.\n /// - $c$ is the cliff amount.\n ///\n /// Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Creates a stream by setting the start time to `block.timestamp`, and the end time to\n /// the sum of `block.timestamp` and `params.durations.total`. The stream is funded by `msg.sender` and is wrapped\n /// in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Requirements:\n /// - All requirements in {createWithRange} must be met for the calculated parameters.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithDurations(LockupLinear.CreateWithDurations calldata params)\n external\n returns (uint256 streamId);\n\n /// @notice Creates a stream with the provided start time and end time as the range. The stream is\n /// funded by `msg.sender` and is wrapped in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Notes:\n /// - As long as the times are ordered, it is not an error for the start or the cliff time to be in the past.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `params.totalAmount` must be greater than zero.\n /// - If set, `params.broker.fee` must not be greater than `MAX_FEE`.\n /// - `params.range.start` must be less than or equal to `params.range.cliff`.\n /// - `params.range.cliff` must be less than `params.range.end`.\n /// - `params.range.end` must be in the future.\n /// - `params.recipient` must not be the zero address.\n /// - `msg.sender` must have allowed this contract to spend at least `params.totalAmount` assets.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2NFTDescriptor.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The id of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);\n}\n" - }, - "@sablier/v2-core/src/types/DataTypes.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD2x18 } from \"@prb/math/src/UD2x18.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units\n /// of the asset's decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in\n /// the same slot saves gas.\n /// @param deposited The initial amount deposited in the stream, net of fees.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating the deposit amount, the protocol fee amount, and the broker fee amount,\n /// all denoted in units of the asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param protocolFee The protocol fee amount.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 protocolFee;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value STREAMING Active stream where assets are currently being streamed.\n /// @custom:value SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING, // value 0\n STREAMING, // value 1\n SETTLED, // value 2\n CANCELED, // value 3\n DEPLETED // value 4\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithDeltas} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments with deltas used to compose the custom streaming curve. Milestones are calculated by\n /// starting from `block.timestamp` and adding each delta to the previous milestone.\n struct CreateWithDeltas {\n address sender;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n SegmentWithDelta[] segments;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithMilestones}\n /// function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments used to compose the custom streaming curve.\n struct CreateWithMilestones {\n address sender;\n uint40 startTime;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Range {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param milestone The Unix timestamp indicating this segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 milestone;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDeltas}.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param delta The time difference in seconds between this segment and the previous one.\n struct SegmentWithDelta {\n uint128 amount;\n UD2x18 exponent;\n uint40 delta;\n }\n\n /// @notice Lockup Dynamic stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n /// @param segments Segments used to compose the custom streaming curve.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n // slots [4..n]\n Segment[] segments;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithRange} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithRange {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Range range;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end.\n /// @param end The Unix timestamp for the stream's end.\n struct Range {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n /// @notice Lockup Linear stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cliffTime The Unix timestamp indicating the cliff period's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 cliffTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n" - }, - "contracts/interfaces/IDexAggregator.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IDexAggregator {\n struct FormattedOffer {\n uint256[] amounts;\n address[] adapters;\n address[] path;\n uint256 gasEstimate;\n }\n\n struct Trade {\n uint256 amountIn;\n uint256 amountOut;\n address[] path;\n address[] adapters;\n }\n\n function findBestPath(\n uint256 _amountIn,\n address _tokenIn,\n address _tokenOut,\n uint256 _maxSteps\n ) external view returns (FormattedOffer memory);\n\n function swapNoSplitFromAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external payable;\n\n function swapNoSplitToAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n\n function swapNoSplit(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n}\n" - }, - "contracts/interfaces/INonfungiblePositionManager.sol": { - "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Non-fungible token for positions\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\n/// and authorized.\ninterface INonfungiblePositionManager {\n struct MintParams {\n address token0;\n address token1;\n uint24 fee;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n address recipient;\n uint256 deadline;\n }\n\n /// @notice Creates a new position wrapped in a NFT\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\n /// a method does not exist, i.e. the pool is assumed to be initialized.\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\n /// @return tokenId The ID of the token that represents the minted position\n /// @return liquidity The amount of liquidity for this position\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\n function mint(\n MintParams calldata params\n )\n external\n payable\n returns (\n uint256 tokenId,\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n}\n" - }, - "contracts/interfaces/IStratosphere.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IStratosphere {\n function tokenIdOf(address _owner) external view returns (uint256);\n\n function mint() external returns (uint256);\n}\n" - }, - "contracts/interfaces/IVaporDEXFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n" - }, - "contracts/interfaces/IVaporDEXRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXRouter {\n function factory() external view returns (address);\n\n function WETH() external view returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n" - }, - "contracts/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ERC20Permit} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IStratosphere} from \"./interfaces/IStratosphere.sol\";\n\nerror Token__MissingLiquidityPool();\nerror Token__ExceedsMaximumHolding();\nerror Token__TradingNotStarted();\nerror Token__NonStratosphereNFTHolder();\nerror Token__BotDetected();\n\ncontract Token is ERC20, ERC20Permit, Ownable {\n address public liquidityPool;\n address public immutable dexAggregator;\n address public immutable dexAdapter;\n uint256 public immutable maxHoldingAmount;\n uint256 public immutable tradingStartsAt;\n IStratosphere public immutable stratosphere;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _supply,\n address _stratosphereAddress,\n address _owner,\n uint256 _tradingStartsAt,\n address _dexAggregator,\n address _dexAdapter\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\n stratosphere = IStratosphere(_stratosphereAddress);\n _mint(msg.sender, _supply);\n maxHoldingAmount = _percentage(_supply, 100); // 1% of total supply\n tradingStartsAt = _tradingStartsAt;\n dexAggregator = _dexAggregator;\n dexAdapter = _dexAdapter;\n }\n\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\n if (_liquidityPool == address(0)) {\n revert Token__MissingLiquidityPool();\n }\n liquidityPool = _liquidityPool;\n }\n\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\n function _update(\n address from,\n address to,\n uint256 value\n ) internal virtual override {\n super._update(from, to, value);\n uint256 _tradingStartsAt = tradingStartsAt;\n\n if (liquidityPool == address(0)) {\n require(\n from == owner() || to == owner(),\n \"Patience - Trading Not Started Yet!\"\n );\n return;\n }\n\n if (block.timestamp < _tradingStartsAt) {\n revert Token__TradingNotStarted();\n }\n\n uint256 _secondsSinceTradingStarted = block.timestamp -\n _tradingStartsAt;\n\n if (_secondsSinceTradingStarted > 24 hours) {\n return;\n }\n\n if (_secondsSinceTradingStarted < 1 hours) {\n _enforceAntiWhale(to, value);\n if (!(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to))) {\n revert Token__NonStratosphereNFTHolder();\n }\n } else if (_secondsSinceTradingStarted < 24 hours) {\n _enforceAntiWhale(to, value);\n }\n }\n\n function _enforceAntiWhale(address to, uint256 value) internal view {\n if (to != liquidityPool) {\n uint256 newBalance = balanceOf(to) + value;\n if (newBalance > maxHoldingAmount) {\n revert Token__ExceedsMaximumHolding();\n }\n }\n }\n\n function _isStratosphereMemberOrAdmin(address _address) internal view returns (bool pass) {\n if (_address == dexAggregator || _address == dexAdapter || stratosphere.tokenIdOf(_address) != 0 ||\n _address == liquidityPool) {\n pass = true;\n }\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n}\n" - }, - "contracts/TokenFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IVaporDEXFactory} from \"./interfaces/IVaporDEXFactory.sol\";\nimport {IVaporDEXRouter} from \"./interfaces/IVaporDEXRouter.sol\";\nimport {Token} from \"./Token.sol\";\nimport {ISablierV2LockupLinear} from \"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\";\nimport {LockupLinear} from \"@sablier/v2-core/src/types/DataTypes.sol\";\nimport {IDexAggregator} from \"./interfaces/IDexAggregator.sol\";\nimport {INonfungiblePositionManager} from \"./interfaces/INonfungiblePositionManager.sol\";\n\nerror TokenFactory__WrongConstructorArguments();\nerror TokenFactory__LiquidityLockedOrDepleted();\nerror TokenFactory__Unauthorized();\nerror TokenFactory__ZeroAddress();\nerror TokenFactory__WrongLaunchArguments();\nerror TokenFactory__InsufficientBalance();\nerror TokenFactory__Invalid();\nerror TokenFactory__TranferFailed(address);\nerror TokenFactory__NotEnoughLiquidity();\nerror TokenFactory__MinimumLockDuration();\n\n/// @title TokenFactory\n/// @author Roy & Jose\n/// @notice This contract is used to launch new tokens and create liquidity for them\n/// @dev Utilizes 'Sablier' for liquidity locking\n\ncontract TokenFactory is Ownable {\n //////////////\n /// EVENTS ///\n //////////////\n\n event TokenLaunched(\n address indexed _tokenAddress,\n address indexed _creatorAddress,\n uint256 indexed _tokenId\n );\n\n event StreamCreated(\n uint256 indexed _streamId,\n address indexed _sender,\n address indexed _pair\n );\n event LiquidityBurned(\n address indexed pair,\n address indexed _burner,\n uint256 _amount\n );\n event LiquidityTokensUnlocked(\n address indexed _pairAddress,\n address indexed _receiver\n );\n event LiquidityTransferred(\n address indexed _pairAddress,\n address indexed _to\n );\n event LaunchFeeUpdated(uint256 _newFee);\n event SlippageUpdated(uint256 _newSlippage);\n event MinimumLiquidityETHUpdated(uint256 _newFee);\n event MinimumLockDurationUpdated(uint40 _newFee);\n event VaporDEXAdapterUpdated(address _newAdapter);\n event EmergencyWithdraw(\n address indexed _token,\n uint256 indexed _amount,\n address indexed _to\n );\n\n ///////////////\n /// STORAGE ///\n ///////////////\n address private immutable factory;\n address private immutable router;\n address private immutable stratosphere;\n IDexAggregator private immutable vaporDexAggregator;\n INonfungiblePositionManager private immutable nonFungiblePositionManager;\n IERC20 private immutable WETH;\n IERC20 private immutable USDC;\n IERC20 private immutable VAPE;\n address private vaporDexAdapter;\n address private teamMultisig;\n uint256 private launchFee;\n uint256 public minLiquidityETH;\n uint256 public slippage;\n uint40 public minLockDuration;\n uint256 public tokenCounter;\n\n mapping(address => uint256[]) private addressToCounters;\n mapping(uint256 => address) private counterToAddress;\n\n // Sablier\n ISablierV2LockupLinear private immutable sablier;\n // Mapping to store the streamId for each pair and lp owner\n mapping(address => mapping(address => uint256)) private liquidityLocks;\n\n /**\n * @dev TokenFactory constructor initializes the contract with required parameters.\n * @param owner Address of the contract owner.\n * @param routerAddress Address of the VaporDEXRouter contract.\n * @param stratosphereAddress Address of the Stratosphere contract.\n * @param vaporDexAggregator Address of the VaporDEX aggregator.\n * @param vaporDexAdapter Address of the VaporDEX adapter.\n * @param usdc Address of the USDC token.\n * @param vape Address of the VAPE token.\n * @param launchFee Launch fee in USDC.\n * @param uint256 minLiquidityETH;\n * @param uint40 minLockDuration;\n * @param sablier Address of the Sablier contract.\n * @param nonFungiblePositionManager Uni v3 NFT Position Manager\n * @param teamMultisig Multisig address\n * @param slippage\n */\n struct DeployArgs {\n address owner;\n address routerAddress;\n address stratosphereAddress;\n address vaporDexAggregator;\n address vaporDexAdapter;\n address usdc;\n address vape;\n uint256 launchFee;\n uint256 minLiquidityETH;\n uint40 minLockDuration;\n address sablier;\n address nonFungiblePositionManager;\n address teamMultisig;\n uint256 slippage;\n }\n\n /////////////////////////\n ////// CONSTRUCTOR /////\n ////////////////////////\n\n constructor(DeployArgs memory args) Ownable(args.owner) {\n // Check for valid constructor arguments\n if (\n args.owner == address(0) ||\n args.routerAddress == address(0) ||\n args.stratosphereAddress == address(0) ||\n args.vaporDexAggregator == address(0) ||\n args.vaporDexAdapter == address(0) ||\n args.usdc == address(0) ||\n args.launchFee == 0 ||\n args.sablier == address(0) ||\n args.minLiquidityETH == 0 ||\n args.minLockDuration == 0\n ) {\n revert TokenFactory__WrongConstructorArguments();\n }\n\n // Initialize variables\n slippage = args.slippage;\n router = args.routerAddress;\n IVaporDEXRouter _router = IVaporDEXRouter(args.routerAddress);\n factory = _router.factory();\n WETH = IERC20(_router.WETH());\n USDC = IERC20(args.usdc);\n VAPE = IERC20(args.vape);\n minLiquidityETH = args.minLiquidityETH;\n minLockDuration = args.minLockDuration;\n\n stratosphere = args.stratosphereAddress;\n vaporDexAggregator = IDexAggregator(args.vaporDexAggregator);\n vaporDexAdapter = args.vaporDexAdapter;\n launchFee = args.launchFee;\n sablier = ISablierV2LockupLinear(args.sablier);\n nonFungiblePositionManager = INonfungiblePositionManager(\n args.nonFungiblePositionManager\n );\n teamMultisig = args.teamMultisig;\n }\n\n /**\n * @dev Launches a new token with specified parameters.\n * @param _name Name of the token.\n * @param _symbol Symbol of the token.\n * @param _totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param lockDuration Number of days to lock liquidity for.\n * @param _burnLiquidity Flag indicating whether to burn liquidity or lock it.\n * @return _pair Address of the created token pair.\n * @return _tokenAddress Address of the launched token.\n * @return streamId Stream ID if liquidity is locked, otherwise 0.\n */\n\n function launch(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint256 _tradingStartsAt,\n uint40 lockDuration,\n bool _burnLiquidity\n )\n external\n payable\n returns (address _pair, address _tokenAddress, uint256 streamId)\n {\n if (msg.value < minLiquidityETH) {\n revert TokenFactory__NotEnoughLiquidity();\n }\n // Step 0: Transfer Fee\n _transferLaunchFee(msg.sender);\n\n // Step 1: Create the token\n Token _token = _createToken(\n _name,\n _symbol,\n _totalSupply,\n _tradingStartsAt,\n address(vaporDexAggregator),\n vaporDexAdapter\n );\n _tokenAddress = address(_token);\n\n // Step 2: Create the pair\n IVaporDEXFactory _factory = IVaporDEXFactory(factory);\n _pair = _factory.createPair(_tokenAddress, address(WETH));\n _token.approve(router, _totalSupply);\n _token.approve(_pair, _totalSupply);\n\n // Step 2: Add Liquidity\n IVaporDEXRouter _router = IVaporDEXRouter(router);\n _router.addLiquidityETH{value: msg.value}(\n _tokenAddress,\n _totalSupply,\n _totalSupply,\n msg.value,\n address(this),\n block.timestamp + 10 minutes\n );\n // Step 3: Get the pair address\n _pair = _factory.getPair(_tokenAddress, address(WETH));\n if (_pair == address(0)) {\n revert TokenFactory__ZeroAddress();\n }\n // Step 4: Set the LP address in the token\n _token.setLiquidityPool(_pair);\n // Step 5: Renounce ownership of the token\n _token.renounceOwnership();\n\n // Step 6: Lock Or Burn Liquidity\n\n IERC20 _lpToken = IERC20(_pair);\n\n if (_burnLiquidity) {\n // Burn Liquidity\n _lpToken.transfer(address(0), _lpToken.balanceOf(address(this)));\n emit LiquidityBurned(\n _pair,\n msg.sender,\n _lpToken.balanceOf(address(this))\n );\n } else {\n if (lockDuration < minLockDuration) {\n revert TokenFactory__MinimumLockDuration();\n }\n _lpToken.approve(\n address(sablier),\n _lpToken.balanceOf(address(this))\n );\n // Lock Liquidity\n // SablierV2\n LockupLinear.CreateWithDurations memory params;\n\n // Declare the function parameters\n params.sender = address(this); // The sender will be able to cancel the stream\n params.recipient = msg.sender; // The recipient of the streamed assets\n params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees\n params.asset = _lpToken; // The streaming asset\n params.cancelable = false; // Whether the stream will be cancelable or not\n params.transferable = true; // Whether the stream will be transferrable or not\n params.durations = LockupLinear.Durations({\n cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period\n total: lockDuration * 1 days\n });\n\n // Create the stream\n streamId = sablier.createWithDurations(params);\n liquidityLocks[msg.sender][_pair] = streamId;\n\n emit StreamCreated(streamId, msg.sender, _pair);\n }\n\n // Step 7: Buy VAPE with USDC on VaporDEXAggregator\n\n _buyVapeWithUsdc(launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee\n\n // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2\n\n _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract\n\n // Step 9: Store the token launch\n emit TokenLaunched(_tokenAddress, msg.sender, tokenCounter);\n\n addressToCounters[msg.sender].push(tokenCounter);\n counterToAddress[tokenCounter] = msg.sender;\n tokenCounter++;\n }\n\n /**\n * @dev Unlocks liquidity tokens for the specified pair and recipient.\n * @param _pair Address of the token pair.\n * @param _receiver Address of the recipient of unlocked tokens.\n * @notice It is recommended to direct the user to Sablier UI for better error handling.\n */\n function unlockLiquidityTokens(address _pair, address _receiver) external {\n if (_receiver == address(0)) {\n revert TokenFactory__ZeroAddress();\n }\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n\n if (streamId == 0) {\n revert TokenFactory__Unauthorized();\n }\n\n uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n revert TokenFactory__LiquidityLockedOrDepleted();\n }\n\n sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier\n\n emit LiquidityTokensUnlocked(_pair, _receiver);\n }\n\n /**\n * @dev Transfers the locked liquidity to the specified recipient for the given pair.\n * @param _pair Address of the token pair.\n * @param _to Address of the recipient.\n */\n function transferLock(address _pair, address _to) external {\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n if (\n streamId == 0 ||\n _to == address(0) ||\n sablier.isTransferable(streamId) == false\n ) {\n revert TokenFactory__Unauthorized();\n }\n\n liquidityLocks[_to][_pair] = streamId;\n liquidityLocks[msg.sender][_pair] = 0;\n\n sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier\n\n emit LiquidityTransferred(_pair, _to);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _liquidity New liquidity.\n */\n\n function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner {\n if (_liquidity == 0) {\n revert TokenFactory__Invalid();\n }\n minLiquidityETH = _liquidity;\n emit MinimumLiquidityETHUpdated(_liquidity);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _slippage New lock duration in days.\n */\n\n function setSlippage(uint256 _slippage) external onlyOwner {\n slippage = _slippage;\n emit SlippageUpdated(_slippage);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _lockDuration New lock duration in days.\n */\n\n function setMinLockDuration(uint40 _lockDuration) external onlyOwner {\n if (_lockDuration == 0) {\n revert TokenFactory__Invalid();\n }\n minLockDuration = _lockDuration;\n emit MinimumLockDurationUpdated(_lockDuration);\n }\n\n /**\n * @dev Sets the launch fee for creating new tokens.\n * @param _launchFee New launch fee in USDC.\n */\n\n function setLaunchFee(uint256 _launchFee) external onlyOwner {\n if (_launchFee == 0) {\n revert TokenFactory__Invalid();\n }\n launchFee = _launchFee;\n emit LaunchFeeUpdated(_launchFee);\n }\n\n /**\n * @dev Sets the VaporDEX adapter address.\n * @param _vaporDexAdapter New VaporDEX adapter address.\n */\n\n function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner {\n if (\n _vaporDexAdapter == vaporDexAdapter ||\n _vaporDexAdapter == address(0)\n ) {\n revert TokenFactory__Invalid();\n }\n vaporDexAdapter = _vaporDexAdapter;\n emit VaporDEXAdapterUpdated(_vaporDexAdapter);\n }\n\n /**\n * @dev Withdraws any stuck tokens (LP Or USDC) to the specified address.\n * @param _token Address of the token to be withdrawn.\n * @param _to Address to which the tokens are withdrawn.\n */\n\n function emergencyWithdraw(address _token, address _to) external onlyOwner {\n if (_to == address(0) || _token == address(0)) {\n revert TokenFactory__ZeroAddress();\n }\n IERC20 token = IERC20(_token);\n uint256 balance = token.balanceOf(address(this));\n if (balance == 0) {\n revert TokenFactory__InsufficientBalance();\n }\n token.transfer(_to, balance);\n emit EmergencyWithdraw(_token, token.balanceOf(address(this)), _to);\n }\n\n /**\n * @dev Creates a new Token contract with specified parameters.\n * @param name Name of the token.\n * @param symbol Symbol of the token.\n * @param totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param dexAggregator Address of the decentralized exchange aggregator.\n * @param dexAdapter Address of the decentralized exchange adapter.\n * @return _token Instance of the created Token contract.\n */\n function _createToken(\n string memory name,\n string memory symbol,\n uint256 totalSupply,\n uint256 _tradingStartsAt,\n address dexAggregator,\n address dexAdapter\n ) internal returns (Token _token) {\n if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) {\n revert TokenFactory__WrongLaunchArguments();\n }\n _token = new Token(\n name,\n symbol,\n totalSupply,\n stratosphere,\n address(this),\n _tradingStartsAt,\n dexAggregator,\n dexAdapter\n );\n }\n\n /**\n * @dev Transfers the launch fee in USDC from the sender.\n * @param _from Address from which the launch fee is transferred.\n */\n\n function _transferLaunchFee(address _from) internal {\n IERC20 _usdc = IERC20(USDC);\n if (_usdc.balanceOf(_from) < launchFee) {\n revert TokenFactory__InsufficientBalance();\n }\n bool isSuccess = _usdc.transferFrom(_from, address(this), launchFee);\n if (!isSuccess) {\n revert TokenFactory__TranferFailed(_from);\n }\n }\n\n /**\n * @dev Buys VAPE with USDC on VaporDEXAggregator\n * @param amountIn Amount of USDC to be used for buying VAPE.\n */\n\n function _buyVapeWithUsdc(uint256 amountIn) internal {\n USDC.approve(address(vaporDexAggregator), amountIn);\n\n IDexAggregator.FormattedOffer memory offer = vaporDexAggregator\n .findBestPath(\n amountIn,\n address(USDC),\n address(VAPE),\n 1 // can be changed to 3\n );\n IDexAggregator.Trade memory trade;\n trade.amountIn = amountIn;\n trade.amountOut = offer.amounts[offer.amounts.length - 1];\n trade.path = offer.path;\n trade.adapters = offer.adapters;\n vaporDexAggregator.swapNoSplit(trade, address(this), 0);\n }\n\n /**\n * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2.\n * @notice Uses the balance of VAPE and USDC in the contract.\n */\n\n function _addLiquidityVapeUsdc() internal {\n uint256 amountInUSDC = USDC.balanceOf(address(this));\n uint256 amountInVAPE = VAPE.balanceOf(address(this));\n USDC.approve(address(nonFungiblePositionManager), amountInUSDC);\n VAPE.approve(address(nonFungiblePositionManager), amountInVAPE);\n INonfungiblePositionManager.MintParams\n memory mintParams = INonfungiblePositionManager.MintParams({\n token0: address(VAPE),\n token1: address(USDC),\n fee: 3000,\n tickLower: -887220, // full range\n tickUpper: 887220, // full range\n amount0Desired: amountInVAPE,\n amount1Desired: amountInUSDC,\n amount0Min: amountInVAPE - _percentage(amountInVAPE, slippage), // 2% slippage\n amount1Min: amountInUSDC - _percentage(amountInUSDC, slippage), // 2% slippage\n recipient: teamMultisig,\n deadline: block.timestamp + 2 minutes\n });\n nonFungiblePositionManager.mint(mintParams);\n\n // Q: What checks should be done with the return values?\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n\n // Getters\n\n /**\n * @dev Returns the launch fee.\n * @return uint256 The launch fee.\n */\n function getLaunchFee() external view returns (uint256) {\n return launchFee;\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDexAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the VaporDEX router.\n * @return address The address of the VaporDEX router.\n */\n function getVaporDEXRouter() external view returns (address) {\n return router;\n }\n\n /**\n * @dev Returns the address of the VaporDEX factory.\n * @return address The address of the VaporDEX factory.\n */\n function getVaporDEXFactory() external view returns (address) {\n return factory;\n }\n\n /**\n * @dev Returns the address of the Stratosphere contract.\n * @return address The address of the Stratosphere contract.\n */\n function getStratosphere() external view returns (address) {\n return stratosphere;\n }\n\n /**\n * @dev Returns the address of the VaporDEX aggregator.\n * @return address The address of the VaporDEX aggregator.\n */\n function getVaporDexAggregator() external view returns (address) {\n return address(vaporDexAggregator);\n }\n\n /**\n * @dev Returns the address of the USDC token.\n * @return address The address of the USDC token.\n */\n function getUSDC() external view returns (address) {\n return address(USDC);\n }\n\n /**\n * @dev Returns the address of the VAPE token.\n * @return address The address of the VAPE token.\n */\n function getVAPE() external view returns (address) {\n return address(VAPE);\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDEXAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the team multisig wallet.\n * @return address The address of the team multisig wallet.\n */\n function getTeamMultisig() external view returns (address) {\n return teamMultisig;\n }\n\n /**\n * @dev Returns the address of the Sablier contract.\n * @return address The address of the Sablier contract.\n */\n function getSablier() external view returns (address) {\n return address(sablier);\n }\n\n /**\n * @dev Returns the address of the NonFungiblePositionManager contract.\n * @return address The address of the NonFungiblePositionManager contract.\n */\n function getNonFungiblePositionManager() external view returns (address) {\n return address(nonFungiblePositionManager);\n }\n\n /**\n * @dev Returns the liquidity lock for the specified pair and owner.\n * @param _pair Address of the token pair.\n * @param _owner Address of the owner.\n * @return uint256 Stream ID for the liquidity lock.\n */\n\n function getLiquidityLock(\n address _pair,\n address _owner\n ) external view returns (uint256) {\n return liquidityLocks[_owner][_pair];\n }\n\n function getTokenLaunch(\n address _owner\n ) external view returns (uint256[] memory) {\n return addressToCounters[_owner];\n }\n\n function getCounterToAddress(\n uint256 _counter\n ) external view returns (address) {\n return counterToAddress[_counter];\n }\n}\n" - } - }, - "settings": { - "evmVersion": "paris", - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/avalancheFuji/solcInputs/1e9204866026dc1fff42496f9b088007.json b/deployments/avalancheFuji/solcInputs/1e9204866026dc1fff42496f9b088007.json deleted file mode 100644 index 117e80e..0000000 --- a/deployments/avalancheFuji/solcInputs/1e9204866026dc1fff42496f9b088007.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" - }, - "@openzeppelin/contracts/interfaces/IERC5267.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n bytes32 private constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Permit deadline has expired.\n */\n error ERC2612ExpiredSignature(uint256 deadline);\n\n /**\n * @dev Mismatched signature.\n */\n error ERC2612InvalidSigner(address signer, address owner);\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @inheritdoc IERC20Permit\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > deadline) {\n revert ERC2612ExpiredSignature(deadline);\n }\n\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n if (signer != owner) {\n revert ERC2612InvalidSigner(signer, owner);\n }\n\n _approve(owner, spender, value);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n return super.nonces(owner);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparatorV4();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n * {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the address zero.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Nonces.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/ShortStrings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" - }, - "@prb/math/src/Common.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" - }, - "@prb/math/src/sd1x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd1x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n" - }, - "@prb/math/src/sd1x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" - }, - "@prb/math/src/sd1x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" - }, - "@prb/math/src/sd59x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd59x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" - }, - "@prb/math/src/sd59x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" - }, - "@prb/math/src/sd59x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/sd59x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" - }, - "@prb/math/src/sd59x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" - }, - "@prb/math/src/UD2x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud2x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud2x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n" - }, - "@prb/math/src/ud2x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" - }, - "@prb/math/src/ud2x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" - }, - "@prb/math/src/UD60x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud60x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud60x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" - }, - "@prb/math/src/ud60x18/Conversions.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" - }, - "@prb/math/src/ud60x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" - }, - "@prb/math/src/ud60x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/ud60x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" - }, - "@prb/math/src/ud60x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" - }, - "@sablier/v2-core/src/interfaces/IAdminable.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Base.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\nimport { ISablierV2Comptroller } from \"./ISablierV2Comptroller.sol\";\n\n/// @title ISablierV2Base\n/// @notice Base logic for all Sablier V2 streaming contracts.\ninterface ISablierV2Base is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin claims all protocol revenues accrued for a particular ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the protocol revenues have been claimed for.\n /// @param protocolRevenues The amount of protocol revenues claimed, denoted in units of the asset's decimals.\n event ClaimProtocolRevenues(address indexed admin, IERC20 indexed asset, uint128 protocolRevenues);\n\n /// @notice Emitted when the admin sets a new comptroller contract.\n /// @param admin The address of the contract admin.\n /// @param oldComptroller The address of the old comptroller contract.\n /// @param newComptroller The address of the new comptroller contract.\n event SetComptroller(\n address indexed admin, ISablierV2Comptroller oldComptroller, ISablierV2Comptroller newComptroller\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the maximum fee that can be charged by the protocol or a broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_FEE() external view returns (UD60x18);\n\n /// @notice Retrieves the address of the comptroller contract, responsible for the Sablier V2 protocol\n /// configuration.\n function comptroller() external view returns (ISablierV2Comptroller);\n\n /// @notice Retrieves the protocol revenues accrued for the provided ERC-20 asset, in units of the asset's\n /// decimals.\n /// @param asset The contract address of the ERC-20 asset to query.\n function protocolRevenues(IERC20 asset) external view returns (uint128 revenues);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Claims all accumulated protocol revenues for the provided ERC-20 asset.\n ///\n /// @dev Emits a {ClaimProtocolRevenues} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset for which to claim protocol revenues.\n function claimProtocolRevenues(IERC20 asset) external;\n\n /// @notice Assigns a new comptroller contract responsible for the protocol configuration.\n ///\n /// @dev Emits a {SetComptroller} event.\n ///\n /// Notes:\n /// - Does not revert if the comptroller is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newComptroller The address of the new comptroller contract.\n function setComptroller(ISablierV2Comptroller newComptroller) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Comptroller.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\n\n/// @title ISablierV2Controller\n/// @notice This contract is in charge of the Sablier V2 protocol configuration, handling such values as the\n/// protocol fees.\ninterface ISablierV2Comptroller is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin sets a new flash fee.\n /// @param admin The address of the contract admin.\n /// @param oldFlashFee The old flash fee, denoted as a fixed-point number.\n /// @param newFlashFee The new flash fee, denoted as a fixed-point number.\n event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);\n\n /// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.\n /// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.\n event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);\n\n /// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset to toggle.\n /// @param newFlag Whether the ERC-20 asset can be flash loaned.\n event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.\n ///\n /// @dev Notes:\n /// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},\n /// which calculates the fee amount for a specified flash loan amount.\n /// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.\n function flashFee() external view returns (UD60x18 fee);\n\n /// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.\n /// @param token The contract address of the ERC-20 asset to check.\n function isFlashAsset(IERC20 token) external view returns (bool result);\n\n /// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.\n /// @param asset The contract address of the ERC-20 asset to query.\n /// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.\n function protocolFees(IERC20 asset) external view returns (UD60x18 fee);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.\n ///\n /// @dev Emits a {SetFlashFee} event.\n ///\n /// Notes:\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.\n function setFlashFee(UD60x18 newFlashFee) external;\n\n /// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.\n ///\n /// @dev Emits a {SetProtocolFee} event.\n ///\n /// Notes:\n /// - The fee is not denoted in units of the asset's decimals; it is a fixed-point number. Refer to the\n /// PRBMath documentation for more detail on the logic of UD60x18.\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset to update the fee for.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.\n function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;\n\n /// @notice Toggles the flash loanability of an ERC-20 asset.\n ///\n /// @dev Emits a {ToggleFlashAsset} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the admin.\n ///\n /// @param asset The address of the ERC-20 asset to toggle.\n function toggleFlashAsset(IERC20 asset) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Lockup.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\nimport { Lockup } from \"../types/DataTypes.sol\";\nimport { ISablierV2Base } from \"./ISablierV2Base.sol\";\nimport { ISablierV2NFTDescriptor } from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup streaming contracts.\ninterface ISablierV2Lockup is\n ISablierV2Base, // 1 inherited component\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The id of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The id of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The id of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset used for streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getEndTime(uint256 streamId) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream id for the query.\n function getRecipient(uint256 streamId) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStartTime(uint256 streamId) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isTransferable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Counter for stream ids, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @param streamId The stream id for the query.\n function statusOf(uint256 streamId) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The id of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The id of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The ids of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The id of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract\n /// and `msg.sender` is either the sender or an approved operator.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `msg.sender` must be the stream's sender, the stream's recipient or an approved third party.\n /// - `to` must be the recipient if `msg.sender` is the stream's sender.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n function withdrawMax(uint256 streamId, address to) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The id of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n function withdrawMaxAndTransfer(uint256 streamId, address newRecipient) external;\n\n /// @notice Withdraws assets from streams to the provided address `to`.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - All requirements from {withdraw} must be met for each stream.\n /// - There must be an equal number of `streamIds` and `amounts`.\n ///\n /// @param streamIds The ids of the streams to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport { Lockup, LockupLinear } from \"../types/DataTypes.sol\";\nimport { ISablierV2Lockup } from \"./ISablierV2Lockup.sol\";\n\n/// @title ISablierV2LockupLinear\n/// @notice Creates and manages Lockup streams with linear streaming functions.\ninterface ISablierV2LockupLinear is ISablierV2Lockup {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is created.\n /// @param streamId The id of the newly created stream.\n /// @param funder The address which funded the stream.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param recipient The address receiving the assets.\n /// @param amounts Struct containing (i) the deposit amount, (ii) the protocol fee amount, and (iii) the\n /// broker fee amount, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Boolean indicating whether the stream will be cancelable or not.\n /// @param transferable Boolean indicating whether the stream NFT is transferable or not.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker The address of the broker who has helped create the stream, e.g. a front-end website.\n event CreateLockupLinearStream(\n uint256 streamId,\n address funder,\n address indexed sender,\n address indexed recipient,\n Lockup.CreateAmounts amounts,\n IERC20 indexed asset,\n bool cancelable,\n bool transferable,\n LockupLinear.Range range,\n address broker\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the stream's cliff time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);\n\n /// @notice Retrieves the stream's range, which is a struct containing (i) the stream's start time, (ii) cliff\n /// time, and (iii) end time, all as Unix timestamps.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);\n\n /// @notice Retrieves the stream entity.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n ///\n /// When the stream is warm, the streaming function is:\n ///\n /// $$\n /// f(x) = x * d + c\n /// $$\n ///\n /// Where:\n ///\n /// - $x$ is the elapsed time divided by the stream's total duration.\n /// - $d$ is the deposited amount.\n /// - $c$ is the cliff amount.\n ///\n /// Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Creates a stream by setting the start time to `block.timestamp`, and the end time to\n /// the sum of `block.timestamp` and `params.durations.total`. The stream is funded by `msg.sender` and is wrapped\n /// in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Requirements:\n /// - All requirements in {createWithRange} must be met for the calculated parameters.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithDurations(LockupLinear.CreateWithDurations calldata params)\n external\n returns (uint256 streamId);\n\n /// @notice Creates a stream with the provided start time and end time as the range. The stream is\n /// funded by `msg.sender` and is wrapped in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Notes:\n /// - As long as the times are ordered, it is not an error for the start or the cliff time to be in the past.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `params.totalAmount` must be greater than zero.\n /// - If set, `params.broker.fee` must not be greater than `MAX_FEE`.\n /// - `params.range.start` must be less than or equal to `params.range.cliff`.\n /// - `params.range.cliff` must be less than `params.range.end`.\n /// - `params.range.end` must be in the future.\n /// - `params.recipient` must not be the zero address.\n /// - `msg.sender` must have allowed this contract to spend at least `params.totalAmount` assets.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2NFTDescriptor.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The id of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);\n}\n" - }, - "@sablier/v2-core/src/types/DataTypes.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD2x18 } from \"@prb/math/src/UD2x18.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units\n /// of the asset's decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in\n /// the same slot saves gas.\n /// @param deposited The initial amount deposited in the stream, net of fees.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating the deposit amount, the protocol fee amount, and the broker fee amount,\n /// all denoted in units of the asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param protocolFee The protocol fee amount.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 protocolFee;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value STREAMING Active stream where assets are currently being streamed.\n /// @custom:value SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING, // value 0\n STREAMING, // value 1\n SETTLED, // value 2\n CANCELED, // value 3\n DEPLETED // value 4\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithDeltas} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments with deltas used to compose the custom streaming curve. Milestones are calculated by\n /// starting from `block.timestamp` and adding each delta to the previous milestone.\n struct CreateWithDeltas {\n address sender;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n SegmentWithDelta[] segments;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithMilestones}\n /// function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments used to compose the custom streaming curve.\n struct CreateWithMilestones {\n address sender;\n uint40 startTime;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Range {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param milestone The Unix timestamp indicating this segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 milestone;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDeltas}.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param delta The time difference in seconds between this segment and the previous one.\n struct SegmentWithDelta {\n uint128 amount;\n UD2x18 exponent;\n uint40 delta;\n }\n\n /// @notice Lockup Dynamic stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n /// @param segments Segments used to compose the custom streaming curve.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n // slots [4..n]\n Segment[] segments;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithRange} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithRange {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Range range;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end.\n /// @param end The Unix timestamp for the stream's end.\n struct Range {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n /// @notice Lockup Linear stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cliffTime The Unix timestamp indicating the cliff period's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 cliffTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n" - }, - "contracts/interfaces/IDexAggregator.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IDexAggregator {\n struct FormattedOffer {\n uint256[] amounts;\n address[] adapters;\n address[] path;\n uint256 gasEstimate;\n }\n\n struct Trade {\n uint256 amountIn;\n uint256 amountOut;\n address[] path;\n address[] adapters;\n }\n\n function findBestPath(\n uint256 _amountIn,\n address _tokenIn,\n address _tokenOut,\n uint256 _maxSteps\n ) external view returns (FormattedOffer memory);\n\n function swapNoSplitFromAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external payable;\n\n function swapNoSplitToAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n\n function swapNoSplit(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n}\n" - }, - "contracts/interfaces/INonfungiblePositionManager.sol": { - "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Non-fungible token for positions\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\n/// and authorized.\ninterface INonfungiblePositionManager {\n struct MintParams {\n address token0;\n address token1;\n uint24 fee;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n address recipient;\n uint256 deadline;\n }\n\n /// @notice Creates a new position wrapped in a NFT\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\n /// a method does not exist, i.e. the pool is assumed to be initialized.\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\n /// @return tokenId The ID of the token that represents the minted position\n /// @return liquidity The amount of liquidity for this position\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\n function mint(\n MintParams calldata params\n )\n external\n payable\n returns (\n uint256 tokenId,\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n}\n" - }, - "contracts/interfaces/IStratosphere.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IStratosphere {\n function tokenIdOf(address _owner) external view returns (uint256);\n\n function mint() external returns (uint256);\n}\n" - }, - "contracts/interfaces/IVaporDEXFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n" - }, - "contracts/interfaces/IVaporDEXRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXRouter {\n function factory() external view returns (address);\n\n function WETH() external view returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n" - }, - "contracts/MemeFactory.sol": { - "content": "// ███╗░░░███╗███████╗███╗░░░███╗███████╗ ███████╗░█████╗░░█████╗░████████╗░█████╗░██████╗░██╗░░░██╗\n// ████╗░████║██╔════╝████╗░████║██╔════╝ ██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗██╔══██╗╚██╗░██╔╝\n// ██╔████╔██║█████╗░░██╔████╔██║█████╗░░ █████╗░░███████║██║░░╚═╝░░░██║░░░██║░░██║██████╔╝░╚████╔╝░\n// ██║╚██╔╝██║██╔══╝░░██║╚██╔╝██║██╔══╝░░ ██╔══╝░░██╔══██║██║░░██╗░░░██║░░░██║░░██║██╔══██╗░░╚██╔╝░░\n// ██║░╚═╝░██║███████╗██║░╚═╝░██║███████╗ ██║░░░░░██║░░██║╚█████╔╝░░░██║░░░╚█████╔╝██║░░██║░░░██║░░░\n// ╚═╝░░░░░╚═╝╚══════╝╚═╝░░░░░╚═╝╚══════╝ ╚═╝░░░░░╚═╝░░╚═╝░╚════╝░░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝░░░╚═╝░░░\n\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IVaporDEXFactory} from \"./interfaces/IVaporDEXFactory.sol\";\nimport {IVaporDEXRouter} from \"./interfaces/IVaporDEXRouter.sol\";\nimport {Token} from \"./Token.sol\";\nimport {ISablierV2LockupLinear} from \"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\";\nimport {LockupLinear} from \"@sablier/v2-core/src/types/DataTypes.sol\";\nimport {IDexAggregator} from \"./interfaces/IDexAggregator.sol\";\nimport {INonfungiblePositionManager} from \"./interfaces/INonfungiblePositionManager.sol\";\n\nerror MemeFactory__WrongConstructorArguments();\nerror MemeFactory__LiquidityLockedOrDepleted();\nerror MemeFactory__Unauthorized();\nerror MemeFactory__ZeroAddress();\nerror MemeFactory__WrongLaunchArguments();\nerror MemeFactory__InsufficientBalance();\nerror MemeFactory__Invalid();\nerror MemeFactory__TranferFailed(address);\nerror MemeFactory__NotEnoughLiquidity();\nerror MemeFactory__MinimumLockDuration();\n\n/// @title MemeFactory\n/// @author Roy & Jose\n/// @notice This contract is used to launch new tokens and create liquidity for them\n/// @dev Utilizes 'Sablier' for liquidity locking\n\ncontract MemeFactory is Ownable {\n //////////////\n /// EVENTS ///\n //////////////\n\n event TokenLaunched(\n address indexed _tokenAddress,\n address indexed _pairAddress,\n bool _liquidityBurned\n );\n\n event StreamCreated(uint256 indexed _streamId);\n event LiquidityBurned(\n address indexed pair,\n address indexed _burner,\n uint256 _amount\n );\n event LiquidityTokensUnlocked(\n address indexed _pairAddress,\n address indexed _receiver\n );\n event LiquidityTransferred(\n address indexed _pairAddress,\n address indexed _to\n );\n event LaunchFeeUpdated(uint256 _newFee);\n event SlippageUpdated(uint256 _newSlippage);\n event MinimumLiquidityETHUpdated(uint256 _newFee);\n event MinimumLockDurationUpdated(uint40 _newFee);\n event VaporDEXAdapterUpdated(address _newAdapter);\n event AccumulatedFeesWithdrawn(address _to, uint256 _amount);\n\n ///////////////\n /// STORAGE ///\n ///////////////\n address private immutable factory;\n address private immutable router;\n address private immutable stratosphere;\n IDexAggregator private immutable vaporDexAggregator;\n INonfungiblePositionManager private immutable nonFungiblePositionManager;\n IERC20 private immutable WETH;\n IERC20 private immutable USDC;\n IERC20 private immutable VAPE;\n address private vaporDexAdapter;\n address private teamMultisig;\n uint256 private launchFee;\n uint256 public minLiquidityETH;\n uint256 public slippage;\n uint40 public minLockDuration;\n\n // Sablier\n ISablierV2LockupLinear private immutable sablier;\n // Mapping to store the streamId for each pair and lp owner\n mapping(address => mapping(address => uint256)) private liquidityLocks;\n\n /**\n * @dev MemeFactory constructor initializes the contract with required parameters.\n * @param owner Address of the contract owner.\n * @param routerAddress Address of the VaporDEXRouter contract.\n * @param stratosphereAddress Address of the Stratosphere contract.\n * @param vaporDexAggregator Address of the VaporDEX aggregator.\n * @param vaporDexAdapter Address of the VaporDEX adapter.\n * @param usdc Address of the USDC token.\n * @param vape Address of the VAPE token.\n * @param launchFee Launch fee in USDC.\n * @param uint256 minLiquidityETH;\n * @param uint40 minLockDuration;\n * @param sablier Address of the Sablier contract.\n * @param nonFungiblePositionManager Uni v3 NFT Position Manager\n * @param teamMultisig Multisig address\n * @param slippage\n */\n struct DeployArgs {\n address owner;\n address routerAddress;\n address stratosphereAddress;\n address vaporDexAggregator;\n address vaporDexAdapter;\n address usdc;\n address vape;\n uint256 launchFee;\n uint256 minLiquidityETH;\n uint40 minLockDuration;\n address sablier;\n address nonFungiblePositionManager;\n address teamMultisig;\n uint256 slippage;\n }\n\n /////////////////////////\n ////// CONSTRUCTOR /////\n ////////////////////////\n\n constructor(DeployArgs memory args) Ownable(args.owner) {\n // Check for valid constructor arguments\n if (\n args.owner == address(0) ||\n args.routerAddress == address(0) ||\n args.stratosphereAddress == address(0) ||\n args.vaporDexAggregator == address(0) ||\n args.vaporDexAdapter == address(0) ||\n args.usdc == address(0) ||\n args.launchFee == 0 ||\n args.sablier == address(0) ||\n args.minLiquidityETH == 0 ||\n args.minLockDuration == 0\n ) {\n revert MemeFactory__WrongConstructorArguments();\n }\n\n // Initialize variables\n slippage = args.slippage;\n router = args.routerAddress;\n IVaporDEXRouter _router = IVaporDEXRouter(args.routerAddress);\n factory = _router.factory();\n WETH = IERC20(_router.WETH());\n USDC = IERC20(args.usdc);\n VAPE = IERC20(args.vape);\n minLiquidityETH = args.minLiquidityETH;\n minLockDuration = args.minLockDuration;\n\n stratosphere = args.stratosphereAddress;\n vaporDexAggregator = IDexAggregator(args.vaporDexAggregator);\n vaporDexAdapter = args.vaporDexAdapter;\n launchFee = args.launchFee;\n sablier = ISablierV2LockupLinear(args.sablier);\n nonFungiblePositionManager = INonfungiblePositionManager(\n args.nonFungiblePositionManager\n );\n teamMultisig = args.teamMultisig;\n }\n\n /**\n * @dev Launches a new token with specified parameters.\n * @param _name Name of the token.\n * @param _symbol Symbol of the token.\n * @param _totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param lockDuration Number of days to lock liquidity for.\n * @param _burnLiquidity Flag indicating whether to burn liquidity or lock it.\n * @return _pair Address of the created token pair.\n * @return _tokenAddress Address of the launched token.\n * @return streamId Stream ID if liquidity is locked, otherwise 0.\n */\n\n function launch(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint256 _tradingStartsAt,\n uint40 lockDuration,\n bool _burnLiquidity\n )\n external\n payable\n returns (address _pair, address _tokenAddress, uint256 streamId)\n {\n uint256 value = msg.value;\n if (value < minLiquidityETH) {\n revert MemeFactory__NotEnoughLiquidity();\n }\n // Step 0: Transfer Fee\n _transferLaunchFee(msg.sender);\n\n // Step 1: Create the token\n Token _token = _createToken(\n _name,\n _symbol,\n _totalSupply,\n _tradingStartsAt,\n address(vaporDexAggregator),\n vaporDexAdapter\n );\n _tokenAddress = address(_token);\n\n // Step 2: Create the pair\n IVaporDEXFactory _factory = IVaporDEXFactory(factory);\n _pair = _factory.createPair(_tokenAddress, address(WETH));\n _token.approve(router, _totalSupply);\n _token.approve(_pair, _totalSupply);\n\n // Step 2: Add Liquidity\n IVaporDEXRouter _router = IVaporDEXRouter(router);\n _router.addLiquidityETH{value: value}(\n _tokenAddress,\n _totalSupply,\n _totalSupply,\n value,\n address(this),\n block.timestamp + 10 minutes\n );\n // Step 3: Get the pair address\n _pair = IVaporDEXFactory(factory).getPair(_tokenAddress, address(WETH));\n if (_pair == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n // Step 4: Set the LP address in the token\n _token.setLiquidityPool(_pair);\n // Step 5: Renounce ownership of the token\n _token.renounceOwnership();\n\n // Step 6: Lock Or Burn Liquidity\n\n IERC20 _lpToken = IERC20(_pair);\n\n if (_burnLiquidity) {\n // Burn Liquidity\n _lpToken.transfer(address(0), _lpToken.balanceOf(address(this)));\n emit LiquidityBurned(\n _pair,\n msg.sender,\n _lpToken.balanceOf(address(this))\n );\n } else {\n if (lockDuration < minLockDuration) {\n revert MemeFactory__MinimumLockDuration();\n }\n _lpToken.approve(\n address(sablier),\n _lpToken.balanceOf(address(this))\n );\n // Lock Liquidity\n // SablierV2\n LockupLinear.CreateWithDurations memory params;\n\n // Declare the function parameters\n params.sender = address(this); // The sender will be able to cancel the stream\n params.recipient = msg.sender; // The recipient of the streamed assets\n params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees\n params.asset = _lpToken; // The streaming asset\n params.cancelable = false; // Whether the stream will be cancelable or not\n params.transferable = true; // Whether the stream will be transferrable or not\n params.durations = LockupLinear.Durations({\n cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period\n total: lockDuration * 1 days\n });\n\n // Create the stream\n streamId = sablier.createWithDurations(params);\n liquidityLocks[msg.sender][_pair] = streamId;\n\n emit StreamCreated(streamId);\n }\n\n // Step 7: Buy VAPE with USDC on VaporDEXAggregator\n\n _buyVapeWithUsdc(launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee\n\n // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2\n\n _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract\n\n emit TokenLaunched(_tokenAddress, _pair, _burnLiquidity);\n }\n\n /**\n * @dev Unlocks liquidity tokens for the specified pair and recipient.\n * @param _pair Address of the token pair.\n * @param _receiver Address of the recipient of unlocked tokens.\n * @notice It is recommended to direct the user to Sablier UI for better error handling.\n */\n function unlockLiquidityTokens(address _pair, address _receiver) external {\n if (_receiver == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n\n if (streamId == 0) {\n revert MemeFactory__Unauthorized();\n }\n\n uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n revert MemeFactory__LiquidityLockedOrDepleted();\n }\n\n sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier\n\n emit LiquidityTokensUnlocked(_pair, _receiver);\n }\n\n /**\n * @dev Transfers the locked liquidity to the specified recipient for the given pair.\n * @param _pair Address of the token pair.\n * @param _to Address of the recipient.\n */\n function transferLock(address _pair, address _to) external {\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n if (\n streamId == 0 ||\n _to == address(0) ||\n sablier.isTransferable(streamId) == false\n ) {\n revert MemeFactory__Unauthorized();\n }\n\n liquidityLocks[_to][_pair] = streamId;\n liquidityLocks[msg.sender][_pair] = 0;\n\n sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier\n\n emit LiquidityTransferred(_pair, _to);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _liquidity New liquidity.\n */\n\n function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner {\n if (_liquidity == 0) {\n revert MemeFactory__Invalid();\n }\n minLiquidityETH = _liquidity;\n emit MinimumLiquidityETHUpdated(_liquidity);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _slippage New lock duration in days.\n */\n\n function setSlippage(uint256 _slippage) external onlyOwner {\n slippage = _slippage;\n emit SlippageUpdated(_slippage);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _lockDuration New lock duration in days.\n */\n\n function setMinLockDuration(uint40 _lockDuration) external onlyOwner {\n if (_lockDuration == 0) {\n revert MemeFactory__Invalid();\n }\n minLockDuration = _lockDuration;\n emit MinimumLockDurationUpdated(_lockDuration);\n }\n\n /**\n * @dev Sets the launch fee for creating new tokens.\n * @param _launchFee New launch fee in USDC.\n */\n\n function setLaunchFee(uint256 _launchFee) external onlyOwner {\n if (_launchFee == 0) {\n revert MemeFactory__Invalid();\n }\n launchFee = _launchFee;\n emit LaunchFeeUpdated(_launchFee);\n }\n\n /**\n * @dev Sets the VaporDEX adapter address.\n * @param _vaporDexAdapter New VaporDEX adapter address.\n */\n\n function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner {\n if (\n _vaporDexAdapter == vaporDexAdapter ||\n _vaporDexAdapter == address(0)\n ) {\n revert MemeFactory__Invalid();\n }\n vaporDexAdapter = _vaporDexAdapter;\n emit VaporDEXAdapterUpdated(_vaporDexAdapter);\n }\n\n /**\n * @dev Withdraws any remaining USDC fees to the specified address.\n * @param _to Address to which the remaining fees are withdrawn.\n */\n\n function withdrawFee(address _to) external onlyOwner {\n if (_to == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n IERC20 _usdc = IERC20(USDC);\n _usdc.transfer(_to, _usdc.balanceOf(address(this)));\n emit AccumulatedFeesWithdrawn(_to, _usdc.balanceOf(address(this)));\n }\n\n /**\n * @dev Creates a new Token contract with specified parameters.\n * @param name Name of the token.\n * @param symbol Symbol of the token.\n * @param totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param dexAggregator Address of the decentralized exchange aggregator.\n * @param dexAdapter Address of the decentralized exchange adapter.\n * @return _token Instance of the created Token contract.\n */\n function _createToken(\n string memory name,\n string memory symbol,\n uint256 totalSupply,\n uint256 _tradingStartsAt,\n address dexAggregator,\n address dexAdapter\n ) internal returns (Token _token) {\n if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) {\n revert MemeFactory__WrongLaunchArguments();\n }\n _token = new Token(\n name,\n symbol,\n totalSupply,\n stratosphere,\n address(this),\n _tradingStartsAt,\n dexAggregator,\n dexAdapter\n );\n }\n\n /**\n * @dev Transfers the launch fee in USDC from the sender.\n * @param _from Address from which the launch fee is transferred.\n */\n\n function _transferLaunchFee(address _from) internal {\n IERC20 _usdc = IERC20(USDC);\n if (_usdc.balanceOf(_from) < launchFee) {\n revert MemeFactory__InsufficientBalance();\n }\n bool isSuccess = _usdc.transferFrom(_from, address(this), launchFee);\n if (!isSuccess) {\n revert MemeFactory__TranferFailed(_from);\n }\n }\n\n /**\n * @dev Buys VAPE with USDC on VaporDEXAggregator\n * @param amountIn Amount of USDC to be used for buying VAPE.\n */\n\n function _buyVapeWithUsdc(uint256 amountIn) internal {\n USDC.approve(address(vaporDexAggregator), amountIn);\n\n IDexAggregator.FormattedOffer memory offer = vaporDexAggregator\n .findBestPath(\n amountIn,\n address(USDC),\n address(VAPE),\n 1 // can be changed to 3\n );\n IDexAggregator.Trade memory trade;\n trade.amountIn = amountIn;\n trade.amountOut = offer.amounts[offer.amounts.length - 1];\n trade.path = offer.path;\n trade.adapters = offer.adapters;\n vaporDexAggregator.swapNoSplit(trade, address(this), 0);\n }\n\n /**\n * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2.\n * @notice Uses the balance of VAPE and USDC in the contract.\n */\n\n function _addLiquidityVapeUsdc() internal {\n uint256 amountInUSDC = USDC.balanceOf(address(this));\n uint256 amountInVAPE = VAPE.balanceOf(address(this));\n USDC.approve(address(nonFungiblePositionManager), amountInUSDC);\n VAPE.approve(address(nonFungiblePositionManager), amountInVAPE);\n INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager\n .MintParams({\n token0: address(VAPE),\n token1: address(USDC),\n fee: 3000,\n tickLower: -887220, // full range\n tickUpper: 887220, // full range\n amount0Desired: amountInVAPE,\n amount1Desired: amountInUSDC,\n amount0Min: amountInVAPE - _percentage(amountInVAPE, slippage), // 2% slippage\n amount1Min: amountInUSDC - _percentage(amountInUSDC, slippage), // 2% slippage\n recipient: teamMultisig,\n deadline: block.timestamp + 2 minutes\n });\n nonFungiblePositionManager.mint(mintParams);\n\n // Q: What checks should be done with the return values?\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n\n // Getters\n\n /**\n * @dev Returns the launch fee.\n * @return uint256 The launch fee.\n */\n function getLaunchFee() external view returns (uint256) {\n return launchFee;\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDexAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the VaporDEX router.\n * @return address The address of the VaporDEX router.\n */\n function getVaporDEXRouter() external view returns (address) {\n return router;\n }\n\n /**\n * @dev Returns the address of the VaporDEX factory.\n * @return address The address of the VaporDEX factory.\n */\n function getVaporDEXFactory() external view returns (address) {\n return factory;\n }\n\n /**\n * @dev Returns the address of the Stratosphere contract.\n * @return address The address of the Stratosphere contract.\n */\n function getStratosphere() external view returns (address) {\n return stratosphere;\n }\n\n /**\n * @dev Returns the address of the VaporDEX aggregator.\n * @return address The address of the VaporDEX aggregator.\n */\n function getVaporDexAggregator() external view returns (address) {\n return address(vaporDexAggregator);\n }\n\n /**\n * @dev Returns the address of the USDC token.\n * @return address The address of the USDC token.\n */\n function getUSDC() external view returns (address) {\n return address(USDC);\n }\n\n /**\n * @dev Returns the address of the VAPE token.\n * @return address The address of the VAPE token.\n */\n function getVAPE() external view returns (address) {\n return address(VAPE);\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDEXAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the team multisig wallet.\n * @return address The address of the team multisig wallet.\n */\n function getTeamMultisig() external view returns (address) {\n return teamMultisig;\n }\n\n /**\n * @dev Returns the address of the Sablier contract.\n * @return address The address of the Sablier contract.\n */\n function getSablier() external view returns (address) {\n return address(sablier);\n }\n\n /**\n * @dev Returns the address of the NonFungiblePositionManager contract.\n * @return address The address of the NonFungiblePositionManager contract.\n */\n function getNonFungiblePositionManager() external view returns (address) {\n return address(nonFungiblePositionManager);\n }\n\n /**\n * @dev Returns the liquidity lock for the specified pair and owner.\n * @param _pair Address of the token pair.\n * @param _owner Address of the owner.\n * @return uint256 Stream ID for the liquidity lock.\n */\n\n function getLiquidityLock(\n address _pair,\n address _owner\n ) external view returns (uint256) {\n return liquidityLocks[_owner][_pair];\n }\n}\n" - }, - "contracts/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ERC20Permit} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IStratosphere} from \"./interfaces/IStratosphere.sol\";\n\nerror Token__MissingLiquidityPool();\nerror Token__ExceedsMaximumHolding();\nerror Token__TradingNotStarted();\nerror Token__NonStratosphereNFTHolder();\nerror Token__BotDetected();\n\ncontract Token is ERC20, ERC20Permit, Ownable {\n address public liquidityPool;\n address public immutable dexAggregator;\n address public immutable dexAdapter;\n uint256 public immutable maxHoldingAmount;\n uint256 public immutable tradingStartsAt;\n IStratosphere public immutable stratosphere;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _supply,\n address _stratosphereAddress,\n address _owner,\n uint256 _tradingStartsAt,\n address _dexAggregator,\n address _dexAdapter\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\n stratosphere = IStratosphere(_stratosphereAddress);\n _mint(msg.sender, _supply);\n maxHoldingAmount = _percentage(_supply, 100); // 1% of total supply\n tradingStartsAt = _tradingStartsAt;\n dexAggregator = _dexAggregator;\n dexAdapter = _dexAdapter;\n }\n\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\n if (_liquidityPool == address(0)) {\n revert Token__MissingLiquidityPool();\n }\n liquidityPool = _liquidityPool;\n }\n\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\n function _update(\n address from,\n address to,\n uint256 value\n ) internal virtual override {\n super._update(from, to, value);\n uint256 _tradingStartsAt = tradingStartsAt;\n\n if (liquidityPool == address(0)) {\n require(\n from == owner() || to == owner(),\n \"Patience - Trading Not Started Yet!\"\n );\n return;\n }\n\n if (block.timestamp < _tradingStartsAt) {\n revert Token__TradingNotStarted();\n }\n\n uint256 _secondsSinceTradingStarted = block.timestamp -\n _tradingStartsAt;\n\n if (_secondsSinceTradingStarted > 24 hours) {\n return;\n }\n\n if (_secondsSinceTradingStarted < 1 hours) {\n _enforceAntiWhale(to, value);\n if (!(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to))) {\n revert Token__NonStratosphereNFTHolder();\n }\n } else if (_secondsSinceTradingStarted < 24 hours) {\n _enforceAntiWhale(to, value);\n }\n }\n\n function _enforceAntiWhale(address to, uint256 value) internal view {\n if (to != liquidityPool) {\n uint256 newBalance = balanceOf(to) + value;\n if (newBalance > maxHoldingAmount) {\n revert Token__ExceedsMaximumHolding();\n }\n }\n }\n\n function _isStratosphereMemberOrAdmin(address _address) internal view returns (bool pass) {\n if (_address == dexAggregator || _address == dexAdapter || stratosphere.tokenIdOf(_address) != 0 ||\n _address == liquidityPool) {\n pass = true;\n }\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n}\n" - } - }, - "settings": { - "evmVersion": "paris", - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/avalancheFuji/solcInputs/1f9ae79be93d069281152f1edc44f21e.json b/deployments/avalancheFuji/solcInputs/1f9ae79be93d069281152f1edc44f21e.json deleted file mode 100644 index b2f861e..0000000 --- a/deployments/avalancheFuji/solcInputs/1f9ae79be93d069281152f1edc44f21e.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" - }, - "@openzeppelin/contracts/interfaces/IERC5267.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n bytes32 private constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Permit deadline has expired.\n */\n error ERC2612ExpiredSignature(uint256 deadline);\n\n /**\n * @dev Mismatched signature.\n */\n error ERC2612InvalidSigner(address signer, address owner);\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @inheritdoc IERC20Permit\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > deadline) {\n revert ERC2612ExpiredSignature(deadline);\n }\n\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n if (signer != owner) {\n revert ERC2612InvalidSigner(signer, owner);\n }\n\n _approve(owner, spender, value);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n return super.nonces(owner);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparatorV4();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n * {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the address zero.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Nonces.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/ShortStrings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" - }, - "@prb/math/src/Common.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" - }, - "@prb/math/src/sd1x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd1x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n" - }, - "@prb/math/src/sd1x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" - }, - "@prb/math/src/sd1x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" - }, - "@prb/math/src/sd59x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd59x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" - }, - "@prb/math/src/sd59x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" - }, - "@prb/math/src/sd59x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/sd59x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" - }, - "@prb/math/src/sd59x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" - }, - "@prb/math/src/UD2x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud2x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud2x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n" - }, - "@prb/math/src/ud2x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" - }, - "@prb/math/src/ud2x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" - }, - "@prb/math/src/UD60x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud60x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud60x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" - }, - "@prb/math/src/ud60x18/Conversions.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" - }, - "@prb/math/src/ud60x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" - }, - "@prb/math/src/ud60x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/ud60x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" - }, - "@prb/math/src/ud60x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" - }, - "@sablier/v2-core/src/interfaces/IAdminable.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Base.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\nimport { ISablierV2Comptroller } from \"./ISablierV2Comptroller.sol\";\n\n/// @title ISablierV2Base\n/// @notice Base logic for all Sablier V2 streaming contracts.\ninterface ISablierV2Base is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin claims all protocol revenues accrued for a particular ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the protocol revenues have been claimed for.\n /// @param protocolRevenues The amount of protocol revenues claimed, denoted in units of the asset's decimals.\n event ClaimProtocolRevenues(address indexed admin, IERC20 indexed asset, uint128 protocolRevenues);\n\n /// @notice Emitted when the admin sets a new comptroller contract.\n /// @param admin The address of the contract admin.\n /// @param oldComptroller The address of the old comptroller contract.\n /// @param newComptroller The address of the new comptroller contract.\n event SetComptroller(\n address indexed admin, ISablierV2Comptroller oldComptroller, ISablierV2Comptroller newComptroller\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the maximum fee that can be charged by the protocol or a broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_FEE() external view returns (UD60x18);\n\n /// @notice Retrieves the address of the comptroller contract, responsible for the Sablier V2 protocol\n /// configuration.\n function comptroller() external view returns (ISablierV2Comptroller);\n\n /// @notice Retrieves the protocol revenues accrued for the provided ERC-20 asset, in units of the asset's\n /// decimals.\n /// @param asset The contract address of the ERC-20 asset to query.\n function protocolRevenues(IERC20 asset) external view returns (uint128 revenues);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Claims all accumulated protocol revenues for the provided ERC-20 asset.\n ///\n /// @dev Emits a {ClaimProtocolRevenues} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset for which to claim protocol revenues.\n function claimProtocolRevenues(IERC20 asset) external;\n\n /// @notice Assigns a new comptroller contract responsible for the protocol configuration.\n ///\n /// @dev Emits a {SetComptroller} event.\n ///\n /// Notes:\n /// - Does not revert if the comptroller is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newComptroller The address of the new comptroller contract.\n function setComptroller(ISablierV2Comptroller newComptroller) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Comptroller.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\n\n/// @title ISablierV2Controller\n/// @notice This contract is in charge of the Sablier V2 protocol configuration, handling such values as the\n/// protocol fees.\ninterface ISablierV2Comptroller is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin sets a new flash fee.\n /// @param admin The address of the contract admin.\n /// @param oldFlashFee The old flash fee, denoted as a fixed-point number.\n /// @param newFlashFee The new flash fee, denoted as a fixed-point number.\n event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);\n\n /// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.\n /// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.\n event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);\n\n /// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset to toggle.\n /// @param newFlag Whether the ERC-20 asset can be flash loaned.\n event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.\n ///\n /// @dev Notes:\n /// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},\n /// which calculates the fee amount for a specified flash loan amount.\n /// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.\n function flashFee() external view returns (UD60x18 fee);\n\n /// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.\n /// @param token The contract address of the ERC-20 asset to check.\n function isFlashAsset(IERC20 token) external view returns (bool result);\n\n /// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.\n /// @param asset The contract address of the ERC-20 asset to query.\n /// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.\n function protocolFees(IERC20 asset) external view returns (UD60x18 fee);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.\n ///\n /// @dev Emits a {SetFlashFee} event.\n ///\n /// Notes:\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.\n function setFlashFee(UD60x18 newFlashFee) external;\n\n /// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.\n ///\n /// @dev Emits a {SetProtocolFee} event.\n ///\n /// Notes:\n /// - The fee is not denoted in units of the asset's decimals; it is a fixed-point number. Refer to the\n /// PRBMath documentation for more detail on the logic of UD60x18.\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset to update the fee for.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.\n function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;\n\n /// @notice Toggles the flash loanability of an ERC-20 asset.\n ///\n /// @dev Emits a {ToggleFlashAsset} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the admin.\n ///\n /// @param asset The address of the ERC-20 asset to toggle.\n function toggleFlashAsset(IERC20 asset) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Lockup.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\nimport { Lockup } from \"../types/DataTypes.sol\";\nimport { ISablierV2Base } from \"./ISablierV2Base.sol\";\nimport { ISablierV2NFTDescriptor } from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup streaming contracts.\ninterface ISablierV2Lockup is\n ISablierV2Base, // 1 inherited component\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The id of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The id of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The id of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset used for streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getEndTime(uint256 streamId) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream id for the query.\n function getRecipient(uint256 streamId) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStartTime(uint256 streamId) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isTransferable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Counter for stream ids, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @param streamId The stream id for the query.\n function statusOf(uint256 streamId) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The id of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The id of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The ids of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The id of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract\n /// and `msg.sender` is either the sender or an approved operator.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `msg.sender` must be the stream's sender, the stream's recipient or an approved third party.\n /// - `to` must be the recipient if `msg.sender` is the stream's sender.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n function withdrawMax(uint256 streamId, address to) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The id of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n function withdrawMaxAndTransfer(uint256 streamId, address newRecipient) external;\n\n /// @notice Withdraws assets from streams to the provided address `to`.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - All requirements from {withdraw} must be met for each stream.\n /// - There must be an equal number of `streamIds` and `amounts`.\n ///\n /// @param streamIds The ids of the streams to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport { Lockup, LockupLinear } from \"../types/DataTypes.sol\";\nimport { ISablierV2Lockup } from \"./ISablierV2Lockup.sol\";\n\n/// @title ISablierV2LockupLinear\n/// @notice Creates and manages Lockup streams with linear streaming functions.\ninterface ISablierV2LockupLinear is ISablierV2Lockup {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is created.\n /// @param streamId The id of the newly created stream.\n /// @param funder The address which funded the stream.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param recipient The address receiving the assets.\n /// @param amounts Struct containing (i) the deposit amount, (ii) the protocol fee amount, and (iii) the\n /// broker fee amount, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Boolean indicating whether the stream will be cancelable or not.\n /// @param transferable Boolean indicating whether the stream NFT is transferable or not.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker The address of the broker who has helped create the stream, e.g. a front-end website.\n event CreateLockupLinearStream(\n uint256 streamId,\n address funder,\n address indexed sender,\n address indexed recipient,\n Lockup.CreateAmounts amounts,\n IERC20 indexed asset,\n bool cancelable,\n bool transferable,\n LockupLinear.Range range,\n address broker\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the stream's cliff time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);\n\n /// @notice Retrieves the stream's range, which is a struct containing (i) the stream's start time, (ii) cliff\n /// time, and (iii) end time, all as Unix timestamps.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);\n\n /// @notice Retrieves the stream entity.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n ///\n /// When the stream is warm, the streaming function is:\n ///\n /// $$\n /// f(x) = x * d + c\n /// $$\n ///\n /// Where:\n ///\n /// - $x$ is the elapsed time divided by the stream's total duration.\n /// - $d$ is the deposited amount.\n /// - $c$ is the cliff amount.\n ///\n /// Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Creates a stream by setting the start time to `block.timestamp`, and the end time to\n /// the sum of `block.timestamp` and `params.durations.total`. The stream is funded by `msg.sender` and is wrapped\n /// in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Requirements:\n /// - All requirements in {createWithRange} must be met for the calculated parameters.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithDurations(LockupLinear.CreateWithDurations calldata params)\n external\n returns (uint256 streamId);\n\n /// @notice Creates a stream with the provided start time and end time as the range. The stream is\n /// funded by `msg.sender` and is wrapped in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Notes:\n /// - As long as the times are ordered, it is not an error for the start or the cliff time to be in the past.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `params.totalAmount` must be greater than zero.\n /// - If set, `params.broker.fee` must not be greater than `MAX_FEE`.\n /// - `params.range.start` must be less than or equal to `params.range.cliff`.\n /// - `params.range.cliff` must be less than `params.range.end`.\n /// - `params.range.end` must be in the future.\n /// - `params.recipient` must not be the zero address.\n /// - `msg.sender` must have allowed this contract to spend at least `params.totalAmount` assets.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2NFTDescriptor.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The id of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);\n}\n" - }, - "@sablier/v2-core/src/types/DataTypes.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD2x18 } from \"@prb/math/src/UD2x18.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units\n /// of the asset's decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in\n /// the same slot saves gas.\n /// @param deposited The initial amount deposited in the stream, net of fees.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating the deposit amount, the protocol fee amount, and the broker fee amount,\n /// all denoted in units of the asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param protocolFee The protocol fee amount.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 protocolFee;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value STREAMING Active stream where assets are currently being streamed.\n /// @custom:value SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING, // value 0\n STREAMING, // value 1\n SETTLED, // value 2\n CANCELED, // value 3\n DEPLETED // value 4\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithDeltas} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments with deltas used to compose the custom streaming curve. Milestones are calculated by\n /// starting from `block.timestamp` and adding each delta to the previous milestone.\n struct CreateWithDeltas {\n address sender;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n SegmentWithDelta[] segments;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithMilestones}\n /// function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments used to compose the custom streaming curve.\n struct CreateWithMilestones {\n address sender;\n uint40 startTime;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Range {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param milestone The Unix timestamp indicating this segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 milestone;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDeltas}.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param delta The time difference in seconds between this segment and the previous one.\n struct SegmentWithDelta {\n uint128 amount;\n UD2x18 exponent;\n uint40 delta;\n }\n\n /// @notice Lockup Dynamic stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n /// @param segments Segments used to compose the custom streaming curve.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n // slots [4..n]\n Segment[] segments;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithRange} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithRange {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Range range;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end.\n /// @param end The Unix timestamp for the stream's end.\n struct Range {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n /// @notice Lockup Linear stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cliffTime The Unix timestamp indicating the cliff period's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 cliffTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n" - }, - "contracts/interfaces/IDexAggregator.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IDexAggregator {\n struct FormattedOffer {\n uint256[] amounts;\n address[] adapters;\n address[] path;\n uint256 gasEstimate;\n }\n\n struct Trade {\n uint256 amountIn;\n uint256 amountOut;\n address[] path;\n address[] adapters;\n }\n\n function findBestPath(\n uint256 _amountIn,\n address _tokenIn,\n address _tokenOut,\n uint256 _maxSteps\n ) external view returns (FormattedOffer memory);\n\n function swapNoSplitFromAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external payable;\n\n function swapNoSplitToAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n\n function swapNoSplit(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n}\n" - }, - "contracts/interfaces/INonfungiblePositionManager.sol": { - "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Non-fungible token for positions\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\n/// and authorized.\ninterface INonfungiblePositionManager {\n struct MintParams {\n address token0;\n address token1;\n uint24 fee;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n address recipient;\n uint256 deadline;\n }\n\n /// @notice Creates a new position wrapped in a NFT\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\n /// a method does not exist, i.e. the pool is assumed to be initialized.\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\n /// @return tokenId The ID of the token that represents the minted position\n /// @return liquidity The amount of liquidity for this position\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\n function mint(\n MintParams calldata params\n )\n external\n payable\n returns (\n uint256 tokenId,\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n}\n" - }, - "contracts/interfaces/IStratosphere.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IStratosphere {\n function tokenIdOf(address _owner) external view returns (uint256);\n\n function mint() external returns (uint256);\n}\n" - }, - "contracts/interfaces/IVaporDEXFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n" - }, - "contracts/interfaces/IVaporDEXRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXRouter {\n function factory() external view returns (address);\n\n function WETH() external view returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n" - }, - "contracts/MemeFactory.sol": { - "content": "// ███╗░░░███╗███████╗███╗░░░███╗███████╗ ███████╗░█████╗░░█████╗░████████╗░█████╗░██████╗░██╗░░░██╗\n// ████╗░████║██╔════╝████╗░████║██╔════╝ ██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗██╔══██╗╚██╗░██╔╝\n// ██╔████╔██║█████╗░░██╔████╔██║█████╗░░ █████╗░░███████║██║░░╚═╝░░░██║░░░██║░░██║██████╔╝░╚████╔╝░\n// ██║╚██╔╝██║██╔══╝░░██║╚██╔╝██║██╔══╝░░ ██╔══╝░░██╔══██║██║░░██╗░░░██║░░░██║░░██║██╔══██╗░░╚██╔╝░░\n// ██║░╚═╝░██║███████╗██║░╚═╝░██║███████╗ ██║░░░░░██║░░██║╚█████╔╝░░░██║░░░╚█████╔╝██║░░██║░░░██║░░░\n// ╚═╝░░░░░╚═╝╚══════╝╚═╝░░░░░╚═╝╚══════╝ ╚═╝░░░░░╚═╝░░╚═╝░╚════╝░░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝░░░╚═╝░░░\n\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IVaporDEXFactory} from \"./interfaces/IVaporDEXFactory.sol\";\nimport {IVaporDEXRouter} from \"./interfaces/IVaporDEXRouter.sol\";\nimport {Token} from \"./Token.sol\";\nimport {ISablierV2LockupLinear} from \"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\";\nimport {LockupLinear} from \"@sablier/v2-core/src/types/DataTypes.sol\";\nimport {IDexAggregator} from \"./interfaces/IDexAggregator.sol\";\nimport {INonfungiblePositionManager} from \"./interfaces/INonfungiblePositionManager.sol\";\n\nerror MemeFactory__WrongConstructorArguments();\nerror MemeFactory__LiquidityLockedOrDepleted();\nerror MemeFactory__Unauthorized();\nerror MemeFactory__ZeroAddress();\nerror MemeFactory__WrongLaunchArguments();\nerror MemeFactory__InsufficientBalance();\nerror MemeFactory__Invalid();\nerror MemeFactory__TranferFailed(address);\nerror MemeFactory__NotEnoughLiquidity();\nerror MemeFactory__MinimumLockDuration();\n\n/// @title MemeFactory\n/// @author Roy & Jose\n/// @notice This contract is used to launch new tokens and create liquidity for them\n/// @dev Utilizes 'Sablier' for liquidity locking\n\ncontract MemeFactory is Ownable {\n //////////////\n /// EVENTS ///\n //////////////\n\n event TokenLaunched(\n address indexed _tokenAddress,\n address indexed _pairAddress,\n bool _liquidityBurned\n );\n\n event StreamCreated(uint256 indexed _streamId);\n event LiquidityBurned(\n address indexed pair,\n address indexed _burner,\n uint256 _amount\n );\n event LiquidityTokensUnlocked(\n address indexed _pairAddress,\n address indexed _receiver\n );\n event LiquidityTransferred(\n address indexed _pairAddress,\n address indexed _to\n );\n event LaunchFeeUpdated(uint256 _newFee);\n event MinimumLiquidityETHUpdated(uint256 _newFee);\n event MinimumLockDurationUpdated(uint40 _newFee);\n event VaporDEXAdapterUpdated(address _newAdapter);\n event AccumulatedFeesWithdrawn(address _to, uint256 _amount);\n\n ///////////////\n /// STORAGE ///\n ///////////////\n address private immutable factory;\n address private immutable router;\n address private immutable stratosphere;\n IDexAggregator private immutable vaporDexAggregator;\n INonfungiblePositionManager private immutable nonFungiblePositionManager;\n IERC20 private immutable WETH;\n IERC20 private immutable USDC;\n IERC20 private immutable VAPE;\n address private vaporDexAdapter;\n address private teamMultisig;\n uint256 private launchFee;\n uint256 public minLiquidityETH;\n uint40 public minLockDuration;\n\n // Sablier\n ISablierV2LockupLinear private immutable sablier;\n // Mapping to store the streamId for each pair and lp owner\n mapping(address => mapping(address => uint256)) private liquidityLocks;\n\n /**\n * @dev MemeFactory constructor initializes the contract with required parameters.\n * @param owner Address of the contract owner.\n * @param routerAddress Address of the VaporDEXRouter contract.\n * @param stratosphereAddress Address of the Stratosphere contract.\n * @param vaporDexAggregator Address of the VaporDEX aggregator.\n * @param vaporDexAdapter Address of the VaporDEX adapter.\n * @param usdc Address of the USDC token.\n * @param vape Address of the VAPE token.\n * @param launchFee Launch fee in USDC.\n * @param uint256 minLiquidityETH;\n * @param uint40 minLockDuration;\n * @param sablier Address of the Sablier contract.\n * @param nonFungiblePositionManager Uni v3 NFT Position Manager\n * @param teamMultisig Multisig address\n */\n struct DeployArgs {\n address owner;\n address routerAddress;\n address stratosphereAddress;\n address vaporDexAggregator;\n address vaporDexAdapter;\n address usdc;\n address vape;\n uint256 launchFee;\n uint256 minLiquidityETH;\n uint40 minLockDuration;\n address sablier;\n address nonFungiblePositionManager;\n address teamMultisig;\n }\n\n /////////////////////////\n ////// CONSTRUCTOR /////\n ////////////////////////\n\n constructor(DeployArgs memory args) Ownable(args.owner) {\n // Check for valid constructor arguments\n if (\n args.owner == address(0) ||\n args.routerAddress == address(0) ||\n args.stratosphereAddress == address(0) ||\n args.vaporDexAggregator == address(0) ||\n args.vaporDexAdapter == address(0) ||\n args.usdc == address(0) ||\n args.launchFee == 0 ||\n args.sablier == address(0) ||\n args.minLiquidityETH == 0 ||\n args.minLockDuration == 0\n ) {\n revert MemeFactory__WrongConstructorArguments();\n }\n\n // Initialize variables\n router = args.routerAddress;\n IVaporDEXRouter _router = IVaporDEXRouter(args.routerAddress);\n factory = _router.factory();\n WETH = IERC20(_router.WETH());\n USDC = IERC20(args.usdc);\n VAPE = IERC20(args.vape);\n minLiquidityETH = args.minLiquidityETH;\n minLockDuration = args.minLockDuration;\n stratosphere = args.stratosphereAddress;\n vaporDexAggregator = IDexAggregator(args.vaporDexAggregator);\n vaporDexAdapter = args.vaporDexAdapter;\n launchFee = args.launchFee;\n sablier = ISablierV2LockupLinear(args.sablier);\n nonFungiblePositionManager = INonfungiblePositionManager(\n args.nonFungiblePositionManager\n );\n teamMultisig = args.teamMultisig;\n }\n\n /**\n * @dev Launches a new token with specified parameters.\n * @param _name Name of the token.\n * @param _symbol Symbol of the token.\n * @param _totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param lockDuration Number of days to lock liquidity for.\n * @param _burnLiquidity Flag indicating whether to burn liquidity or lock it.\n * @return _pair Address of the created token pair.\n * @return _tokenAddress Address of the launched token.\n * @return streamId Stream ID if liquidity is locked, otherwise 0.\n */\n\n function launch(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint256 _tradingStartsAt,\n uint40 lockDuration,\n bool _burnLiquidity\n )\n external\n payable\n returns (address _pair, address _tokenAddress, uint256 streamId)\n {\n uint256 value = msg.value;\n if (value < minLiquidityETH) {\n revert MemeFactory__NotEnoughLiquidity();\n }\n // Step 0: Transfer Fee\n _transferLaunchFee(msg.sender);\n\n // Step 1: Create the token\n Token _token = _createToken(\n _name,\n _symbol,\n _totalSupply,\n _tradingStartsAt,\n address(vaporDexAggregator),\n vaporDexAdapter\n );\n _tokenAddress = address(_token);\n\n // Step 2: Create the pair\n IVaporDEXFactory _factory = IVaporDEXFactory(factory);\n _pair = _factory.createPair(_tokenAddress, address(WETH));\n _token.approve(router, _totalSupply);\n _token.approve(_pair, _totalSupply);\n\n // Step 2: Add Liquidity\n IVaporDEXRouter _router = IVaporDEXRouter(router);\n _router.addLiquidityETH{value: value}(\n _tokenAddress,\n _totalSupply,\n _totalSupply,\n value,\n address(this),\n block.timestamp + 10 minutes\n );\n // Step 3: Get the pair address\n _pair = IVaporDEXFactory(factory).getPair(_tokenAddress, address(WETH));\n if (_pair == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n // Step 4: Set the LP address in the token\n _token.setLiquidityPool(_pair);\n // Step 5: Renounce ownership of the token\n _token.renounceOwnership();\n\n // Step 6: Lock Or Burn Liquidity\n\n IERC20 _lpToken = IERC20(_pair);\n\n if (_burnLiquidity) {\n // Burn Liquidity\n _lpToken.transfer(address(0), _lpToken.balanceOf(address(this)));\n emit LiquidityBurned(\n _pair,\n msg.sender,\n _lpToken.balanceOf(address(this))\n );\n } else {\n if (lockDuration < minLockDuration) {\n revert MemeFactory__MinimumLockDuration();\n }\n _lpToken.approve(\n address(sablier),\n _lpToken.balanceOf(address(this))\n );\n // Lock Liquidity\n // SablierV2\n LockupLinear.CreateWithDurations memory params;\n\n // Declare the function parameters\n params.sender = address(this); // The sender will be able to cancel the stream\n params.recipient = msg.sender; // The recipient of the streamed assets\n params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees\n params.asset = _lpToken; // The streaming asset\n params.cancelable = false; // Whether the stream will be cancelable or not\n params.transferable = true; // Whether the stream will be transferrable or not\n params.durations = LockupLinear.Durations({\n cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period\n total: lockDuration * 1 days\n });\n\n // Create the stream\n streamId = sablier.createWithDurations(params);\n liquidityLocks[msg.sender][_pair] = streamId;\n\n emit StreamCreated(streamId);\n }\n\n // Step 7: Buy VAPE with USDC on VaporDEXAggregator\n\n _buyVapeWithUsdc(launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee\n\n // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2\n\n _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract\n\n emit TokenLaunched(_tokenAddress, _pair, _burnLiquidity);\n }\n\n /**\n * @dev Unlocks liquidity tokens for the specified pair and recipient.\n * @param _pair Address of the token pair.\n * @param _receiver Address of the recipient of unlocked tokens.\n * @notice It is recommended to direct the user to Sablier UI for better error handling.\n */\n function unlockLiquidityTokens(address _pair, address _receiver) external {\n if (_receiver == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n\n if (streamId == 0) {\n revert MemeFactory__Unauthorized();\n }\n\n uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n revert MemeFactory__LiquidityLockedOrDepleted();\n }\n\n sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier\n\n emit LiquidityTokensUnlocked(_pair, _receiver);\n }\n\n /**\n * @dev Transfers the locked liquidity to the specified recipient for the given pair.\n * @param _pair Address of the token pair.\n * @param _to Address of the recipient.\n */\n function transferLock(address _pair, address _to) external {\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n if (\n streamId == 0 ||\n _to == address(0) ||\n sablier.isTransferable(streamId) == false\n ) {\n revert MemeFactory__Unauthorized();\n }\n\n liquidityLocks[_to][_pair] = streamId;\n liquidityLocks[msg.sender][_pair] = 0;\n\n sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier\n\n emit LiquidityTransferred(_pair, _to);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _liquidity New liquidity.\n */\n\n function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner {\n if (_liquidity == 0) {\n revert MemeFactory__Invalid();\n }\n minLiquidityETH = _liquidity;\n emit MinimumLiquidityETHUpdated(_liquidity);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _lockDuration New lock duration in days.\n */\n\n function setMinLockDuration(uint40 _lockDuration) external onlyOwner {\n if (_lockDuration == 0) {\n revert MemeFactory__Invalid();\n }\n minLockDuration = _lockDuration;\n emit MinimumLockDurationUpdated(_lockDuration);\n }\n\n /**\n * @dev Sets the launch fee for creating new tokens.\n * @param _launchFee New launch fee in USDC.\n */\n\n function setLaunchFee(uint256 _launchFee) external onlyOwner {\n if (_launchFee == 0) {\n revert MemeFactory__Invalid();\n }\n launchFee = _launchFee;\n emit LaunchFeeUpdated(_launchFee);\n }\n\n /**\n * @dev Sets the VaporDEX adapter address.\n * @param _vaporDexAdapter New VaporDEX adapter address.\n */\n\n function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner {\n if (\n _vaporDexAdapter == vaporDexAdapter ||\n _vaporDexAdapter == address(0)\n ) {\n revert MemeFactory__Invalid();\n }\n vaporDexAdapter = _vaporDexAdapter;\n emit VaporDEXAdapterUpdated(_vaporDexAdapter);\n }\n\n /**\n * @dev Withdraws any remaining USDC fees to the specified address.\n * @param _to Address to which the remaining fees are withdrawn.\n */\n\n function withdrawFee(address _to) external onlyOwner {\n if (_to == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n IERC20 _usdc = IERC20(USDC);\n _usdc.transfer(_to, _usdc.balanceOf(address(this)));\n emit AccumulatedFeesWithdrawn(_to, _usdc.balanceOf(address(this)));\n }\n\n /**\n * @dev Creates a new Token contract with specified parameters.\n * @param name Name of the token.\n * @param symbol Symbol of the token.\n * @param totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param dexAggregator Address of the decentralized exchange aggregator.\n * @param dexAdapter Address of the decentralized exchange adapter.\n * @return _token Instance of the created Token contract.\n */\n function _createToken(\n string memory name,\n string memory symbol,\n uint256 totalSupply,\n uint256 _tradingStartsAt,\n address dexAggregator,\n address dexAdapter\n ) internal returns (Token _token) {\n if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) {\n revert MemeFactory__WrongLaunchArguments();\n }\n _token = new Token(\n name,\n symbol,\n totalSupply,\n stratosphere,\n address(this),\n _tradingStartsAt,\n dexAggregator,\n dexAdapter\n );\n }\n\n /**\n * @dev Transfers the launch fee in USDC from the sender.\n * @param _from Address from which the launch fee is transferred.\n */\n\n function _transferLaunchFee(address _from) internal {\n IERC20 _usdc = IERC20(USDC);\n if (_usdc.balanceOf(_from) < launchFee) {\n revert MemeFactory__InsufficientBalance();\n }\n bool isSuccess = _usdc.transferFrom(_from, address(this), launchFee);\n if (!isSuccess) {\n revert MemeFactory__TranferFailed(_from);\n }\n }\n\n /**\n * @dev Buys VAPE with USDC on VaporDEXAggregator\n * @param amountIn Amount of USDC to be used for buying VAPE.\n */\n\n function _buyVapeWithUsdc(uint256 amountIn) internal {\n USDC.approve(address(vaporDexAggregator), amountIn);\n\n IDexAggregator.FormattedOffer memory offer = vaporDexAggregator\n .findBestPath(\n amountIn,\n address(USDC),\n address(VAPE),\n 1 // can be changed to 3\n );\n IDexAggregator.Trade memory trade;\n trade.amountIn = amountIn;\n trade.amountOut = offer.amounts[offer.amounts.length - 1];\n trade.path = offer.path;\n trade.adapters = offer.adapters;\n vaporDexAggregator.swapNoSplit(trade, address(this), 0);\n }\n\n /**\n * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2.\n * @notice Uses the balance of VAPE and USDC in the contract.\n */\n\n function _addLiquidityVapeUsdc() internal {\n uint256 amountInUSDC = USDC.balanceOf(address(this));\n uint256 amountInVAPE = VAPE.balanceOf(address(this));\n USDC.approve(address(nonFungiblePositionManager), amountInUSDC);\n VAPE.approve(address(nonFungiblePositionManager), amountInVAPE);\n INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager\n .MintParams({\n token0: address(VAPE),\n token1: address(USDC),\n fee: 3000,\n tickLower: -887220, // full range\n tickUpper: 887220, // full range\n amount0Desired: amountInVAPE,\n amount1Desired: amountInUSDC,\n amount0Min: amountInVAPE - _percentage(amountInVAPE, 200), // 2% slippage\n amount1Min: amountInUSDC - _percentage(amountInUSDC, 200), // 2% slippage\n recipient: teamMultisig,\n deadline: block.timestamp + 2 minutes\n });\n nonFungiblePositionManager.mint(mintParams);\n\n // Q: What checks should be done with the return values?\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n\n // Getters\n\n /**\n * @dev Returns the launch fee.\n * @return uint256 The launch fee.\n */\n function getLaunchFee() external view returns (uint256) {\n return launchFee;\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDexAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the VaporDEX router.\n * @return address The address of the VaporDEX router.\n */\n function getVaporDEXRouter() external view returns (address) {\n return router;\n }\n\n /**\n * @dev Returns the address of the VaporDEX factory.\n * @return address The address of the VaporDEX factory.\n */\n function getVaporDEXFactory() external view returns (address) {\n return factory;\n }\n\n /**\n * @dev Returns the address of the Stratosphere contract.\n * @return address The address of the Stratosphere contract.\n */\n function getStratosphere() external view returns (address) {\n return stratosphere;\n }\n\n /**\n * @dev Returns the address of the VaporDEX aggregator.\n * @return address The address of the VaporDEX aggregator.\n */\n function getVaporDexAggregator() external view returns (address) {\n return address(vaporDexAggregator);\n }\n\n /**\n * @dev Returns the address of the USDC token.\n * @return address The address of the USDC token.\n */\n function getUSDC() external view returns (address) {\n return address(USDC);\n }\n\n /**\n * @dev Returns the address of the VAPE token.\n * @return address The address of the VAPE token.\n */\n function getVAPE() external view returns (address) {\n return address(VAPE);\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDEXAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the team multisig wallet.\n * @return address The address of the team multisig wallet.\n */\n function getTeamMultisig() external view returns (address) {\n return teamMultisig;\n }\n\n /**\n * @dev Returns the address of the Sablier contract.\n * @return address The address of the Sablier contract.\n */\n function getSablier() external view returns (address) {\n return address(sablier);\n }\n\n /**\n * @dev Returns the address of the NonFungiblePositionManager contract.\n * @return address The address of the NonFungiblePositionManager contract.\n */\n function getNonFungiblePositionManager() external view returns (address) {\n return address(nonFungiblePositionManager);\n }\n\n /**\n * @dev Returns the liquidity lock for the specified pair and owner.\n * @param _pair Address of the token pair.\n * @param _owner Address of the owner.\n * @return uint256 Stream ID for the liquidity lock.\n */\n\n function getLiquidityLock(\n address _pair,\n address _owner\n ) external view returns (uint256) {\n return liquidityLocks[_owner][_pair];\n }\n}\n" - }, - "contracts/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ERC20Permit} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IStratosphere} from \"./interfaces/IStratosphere.sol\";\n\nerror Token__MissingLiquidityPool();\nerror Token__ExceedsMaximumHolding();\nerror Token__TradingNotStarted();\nerror Token__NonStratosphereNFTHolder();\nerror Token__BotDetected();\n\ncontract Token is ERC20, ERC20Permit, Ownable {\n address public liquidityPool;\n address public immutable dexAggregator;\n address public immutable dexAdapter;\n uint256 public immutable maxHoldingAmount;\n uint256 public immutable tradingStartsAt;\n IStratosphere public immutable stratosphere;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _supply,\n address _stratosphereAddress,\n address _owner,\n uint256 _tradingStartsAt,\n address _dexAggregator,\n address _dexAdapter\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\n stratosphere = IStratosphere(_stratosphereAddress);\n _mint(msg.sender, _supply);\n maxHoldingAmount = _percentage(_supply, 100); // 1% of total supply\n tradingStartsAt = _tradingStartsAt;\n dexAggregator = _dexAggregator;\n dexAdapter = _dexAdapter;\n }\n\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\n if (_liquidityPool == address(0)) {\n revert Token__MissingLiquidityPool();\n }\n liquidityPool = _liquidityPool;\n }\n\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\n function _update(\n address from,\n address to,\n uint256 value\n ) internal virtual override {\n super._update(from, to, value);\n uint256 _tradingStartsAt = tradingStartsAt;\n\n if (liquidityPool == address(0)) {\n require(\n from == owner() || to == owner(),\n \"Patience - Trading Not Started Yet!\"\n );\n return;\n }\n\n if (block.timestamp < _tradingStartsAt) {\n revert Token__TradingNotStarted();\n }\n\n uint256 _secondsSinceTradingStarted = block.timestamp -\n _tradingStartsAt;\n\n if (_secondsSinceTradingStarted > 24 hours) {\n return;\n }\n\n if (_secondsSinceTradingStarted < 1 hours) {\n _enforceAntiWhale(to, value);\n if (!(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to))) {\n revert Token__NonStratosphereNFTHolder();\n }\n } else if (_secondsSinceTradingStarted < 24 hours) {\n _enforceAntiWhale(to, value);\n }\n }\n\n function _enforceAntiWhale(address to, uint256 value) internal view {\n if (to != liquidityPool) {\n uint256 newBalance = balanceOf(to) + value;\n if (newBalance > maxHoldingAmount) {\n revert Token__ExceedsMaximumHolding();\n }\n }\n }\n\n function _isStratosphereMemberOrAdmin(address _address) internal view returns (bool pass) {\n if (_address == dexAggregator || _address == dexAdapter || stratosphere.tokenIdOf(_address) != 0 ||\n _address == liquidityPool) {\n pass = true;\n }\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n}\n" - } - }, - "settings": { - "evmVersion": "paris", - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/avalancheFuji/solcInputs/434b469d2a5b3cf7f401f4d795acc908.json b/deployments/avalancheFuji/solcInputs/434b469d2a5b3cf7f401f4d795acc908.json deleted file mode 100644 index 52fa68a..0000000 --- a/deployments/avalancheFuji/solcInputs/434b469d2a5b3cf7f401f4d795acc908.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" - }, - "@openzeppelin/contracts/interfaces/IERC5267.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n bytes32 private constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Permit deadline has expired.\n */\n error ERC2612ExpiredSignature(uint256 deadline);\n\n /**\n * @dev Mismatched signature.\n */\n error ERC2612InvalidSigner(address signer, address owner);\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @inheritdoc IERC20Permit\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > deadline) {\n revert ERC2612ExpiredSignature(deadline);\n }\n\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n if (signer != owner) {\n revert ERC2612InvalidSigner(signer, owner);\n }\n\n _approve(owner, spender, value);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n return super.nonces(owner);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparatorV4();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n * {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the address zero.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Nonces.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/ShortStrings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" - }, - "contracts/interfaces/IVaporDEXFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n" - }, - "contracts/interfaces/IVaporDEXRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXRouter {\n function factory() external view returns (address);\n\n function WETH() external view returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n" - }, - "contracts/MemeFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {IVaporDEXFactory} from \"./interfaces/IVaporDEXFactory.sol\";\nimport {IVaporDEXRouter} from \"./interfaces/IVaporDEXRouter.sol\";\nimport {Token} from \"./Token.sol\";\n\ncontract MemeFactory is Ownable {\n address public immutable factory;\n address public immutable router;\n address public immutable WETH;\n address public immutable stratosphere;\n address[] public whitelist;\n\n struct LiquidityLock {\n address owner;\n address pair;\n uint256 unlocksAt;\n }\n mapping(address => LiquidityLock) private _pairInfo;\n\n error WrongConstructorArguments();\n error LiquidityStillLocked();\n error Unauthorized();\n error ZeroAddress();\n\n event TokenLaunched(\n address indexed _tokenAddress,\n address indexed _pairAddress\n );\n event LiquidityUnlocked(address indexed _pairAddress, address indexed _to);\n event LiquidityTransferred(\n address indexed _pairAddress,\n address indexed _to\n );\n\n constructor(\n address _owner,\n address _routerAddress,\n address _stratosphereAddress,\n address[] memory _whitelist\n ) Ownable(_owner) {\n if (\n _owner == address(0) ||\n _routerAddress == address(0) ||\n _stratosphereAddress == address(0)\n ) {\n revert WrongConstructorArguments();\n }\n\n router = _routerAddress;\n IVaporDEXRouter _router = IVaporDEXRouter(_routerAddress);\n factory = _router.factory();\n WETH = _router.WETH();\n stratosphere = _stratosphereAddress;\n whitelist = _whitelist;\n }\n\n function launch(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint256 _releaseTime\n ) external payable returns (address _pair, address _tokenAddress) {\n // Step 1: Create the token\n Token _token = _createToken(_name, _symbol, _totalSupply, _releaseTime);\n _tokenAddress = address(_token);\n // Step 2: Add Liquidity\n IVaporDEXRouter _router = IVaporDEXRouter(router);\n _router.addLiquidityETH{value: msg.value}(\n _tokenAddress,\n _totalSupply,\n _totalSupply,\n msg.value,\n address(this),\n block.timestamp + 10 minutes\n );\n // Step 3: Get the pair address\n _pair = IVaporDEXFactory(factory).getPair(_tokenAddress, WETH);\n\n // Step 4: Set the LP address in the token\n _token.setLiquidityPool(_pair);\n // Step 5: Renounce ownership of the token\n _token.renounceOwnership();\n // Step 6: lock the LP tokens for 365 days\n _pairInfo[_pair] = LiquidityLock({\n owner: msg.sender,\n pair: _pair,\n unlocksAt: block.timestamp + 365 days\n });\n\n emit TokenLaunched(_tokenAddress, _pair);\n }\n\n function unlockLiquidity(address _pair, address _to) external {\n if (_pairInfo[_pair].unlocksAt > block.timestamp) {\n revert LiquidityStillLocked();\n }\n if (_pairInfo[_pair].owner != msg.sender) {\n revert Unauthorized();\n }\n _pairInfo[_pair].owner = address(0);\n _pairInfo[_pair].pair = address(0);\n _pairInfo[_pair].unlocksAt = 0;\n\n ERC20 _lpToken = ERC20(_pair);\n _lpToken.transfer(_to, _lpToken.balanceOf(address(this)));\n\n emit LiquidityUnlocked(_pair, _to);\n }\n\n function transferLock(address _pair, address _to) external {\n address _currentOwner = _pairInfo[_pair].owner;\n if (msg.sender != _currentOwner) {\n revert Unauthorized();\n }\n\n _pairInfo[_pair].owner = _to;\n\n emit LiquidityTransferred(_pair, _to);\n }\n\n function _createToken(\n string memory name,\n string memory symbol,\n uint256 totalSupply,\n uint256 _releaseTime\n ) internal returns (Token _token) {\n _token = new Token(\n name,\n symbol,\n totalSupply,\n stratosphere,\n address(this),\n _releaseTime,\n whitelist\n );\n ERC20(address(_token)).approve(router, totalSupply);\n }\n}\n" - }, - "contracts/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ERC20Permit} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\ncontract Token is ERC20, ERC20Permit, Ownable {\n address public liquidityPool;\n uint256 public immutable maxHoldingAmount;\n uint256 public immutable tradingStartsAt;\n IERC721 public immutable stratosphere;\n\n mapping(address => bool) public whitelist;\n\n error Unauthorized();\n error MissingLiquidityPool();\n error ExceedsMaximumHolding();\n error TradingNotStarted();\n error NonStratosphereNFTHolder();\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _supply,\n address _stratosphereAddress,\n address _owner,\n uint256 _tradingStartsAt,\n address[] memory _whitelist\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\n whitelist[msg.sender] = true;\n stratosphere = IERC721(_stratosphereAddress);\n _mint(msg.sender, _supply);\n maxHoldingAmount = _supply / 100; // 1% of total supply\n tradingStartsAt = _tradingStartsAt;\n\n for (uint256 i = 0; i < _whitelist.length; i++) {\n whitelist[_whitelist[i]] = true;\n }\n }\n\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\n if (_liquidityPool == address(0)) {\n revert MissingLiquidityPool();\n }\n liquidityPool = _liquidityPool;\n whitelist[_liquidityPool] = true;\n }\n\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\n function _update(\n address from,\n address to,\n uint256 value\n ) internal virtual override {\n super._update(from, to, value);\n uint256 _tradingStartsAt = tradingStartsAt;\n\n if (block.timestamp < _tradingStartsAt) {\n revert TradingNotStarted();\n }\n\n uint256 _secondsSinceTradingStarted = block.timestamp -\n _tradingStartsAt;\n\n if (_secondsSinceTradingStarted > 24 hours) {\n return;\n }\n\n if (whitelist[from] || whitelist[to]) {\n return;\n }\n\n if (_secondsSinceTradingStarted < 1 hours) {\n _enforceStratosphereHolder(to);\n _enforceAntiWhale(to, value);\n } else if (_secondsSinceTradingStarted < 24 hours) {\n _enforceAntiWhale(to, value);\n }\n }\n\n function _enforceStratosphereHolder(address _address) internal view {\n if (stratosphere.balanceOf(_address) == 0) {\n revert NonStratosphereNFTHolder();\n }\n }\n\n function _enforceAntiWhale(address to, uint256 value) internal view {\n if (to != liquidityPool) {\n uint256 newBalance = balanceOf(to) + value;\n if (newBalance > maxHoldingAmount) {\n revert ExceedsMaximumHolding();\n }\n }\n }\n}\n" - } - }, - "settings": { - "evmVersion": "paris", - "optimizer": { - "enabled": false, - "runs": 200 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/avalancheFuji/solcInputs/5cf4656f8e10c735ea840cf55864e902.json b/deployments/avalancheFuji/solcInputs/5cf4656f8e10c735ea840cf55864e902.json deleted file mode 100644 index 9fb8b39..0000000 --- a/deployments/avalancheFuji/solcInputs/5cf4656f8e10c735ea840cf55864e902.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" - }, - "@openzeppelin/contracts/interfaces/IERC5267.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n bytes32 private constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Permit deadline has expired.\n */\n error ERC2612ExpiredSignature(uint256 deadline);\n\n /**\n * @dev Mismatched signature.\n */\n error ERC2612InvalidSigner(address signer, address owner);\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @inheritdoc IERC20Permit\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > deadline) {\n revert ERC2612ExpiredSignature(deadline);\n }\n\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n if (signer != owner) {\n revert ERC2612InvalidSigner(signer, owner);\n }\n\n _approve(owner, spender, value);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n return super.nonces(owner);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparatorV4();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n * {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the address zero.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Nonces.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/ShortStrings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" - }, - "@prb/math/src/Common.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" - }, - "@prb/math/src/sd1x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd1x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n" - }, - "@prb/math/src/sd1x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" - }, - "@prb/math/src/sd1x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" - }, - "@prb/math/src/sd59x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd59x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" - }, - "@prb/math/src/sd59x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" - }, - "@prb/math/src/sd59x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/sd59x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" - }, - "@prb/math/src/sd59x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" - }, - "@prb/math/src/UD2x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud2x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud2x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n" - }, - "@prb/math/src/ud2x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" - }, - "@prb/math/src/ud2x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" - }, - "@prb/math/src/UD60x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud60x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud60x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" - }, - "@prb/math/src/ud60x18/Conversions.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" - }, - "@prb/math/src/ud60x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" - }, - "@prb/math/src/ud60x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/ud60x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" - }, - "@prb/math/src/ud60x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" - }, - "@sablier/v2-core/src/interfaces/IAdminable.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Base.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\nimport { ISablierV2Comptroller } from \"./ISablierV2Comptroller.sol\";\n\n/// @title ISablierV2Base\n/// @notice Base logic for all Sablier V2 streaming contracts.\ninterface ISablierV2Base is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin claims all protocol revenues accrued for a particular ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the protocol revenues have been claimed for.\n /// @param protocolRevenues The amount of protocol revenues claimed, denoted in units of the asset's decimals.\n event ClaimProtocolRevenues(address indexed admin, IERC20 indexed asset, uint128 protocolRevenues);\n\n /// @notice Emitted when the admin sets a new comptroller contract.\n /// @param admin The address of the contract admin.\n /// @param oldComptroller The address of the old comptroller contract.\n /// @param newComptroller The address of the new comptroller contract.\n event SetComptroller(\n address indexed admin, ISablierV2Comptroller oldComptroller, ISablierV2Comptroller newComptroller\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the maximum fee that can be charged by the protocol or a broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_FEE() external view returns (UD60x18);\n\n /// @notice Retrieves the address of the comptroller contract, responsible for the Sablier V2 protocol\n /// configuration.\n function comptroller() external view returns (ISablierV2Comptroller);\n\n /// @notice Retrieves the protocol revenues accrued for the provided ERC-20 asset, in units of the asset's\n /// decimals.\n /// @param asset The contract address of the ERC-20 asset to query.\n function protocolRevenues(IERC20 asset) external view returns (uint128 revenues);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Claims all accumulated protocol revenues for the provided ERC-20 asset.\n ///\n /// @dev Emits a {ClaimProtocolRevenues} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset for which to claim protocol revenues.\n function claimProtocolRevenues(IERC20 asset) external;\n\n /// @notice Assigns a new comptroller contract responsible for the protocol configuration.\n ///\n /// @dev Emits a {SetComptroller} event.\n ///\n /// Notes:\n /// - Does not revert if the comptroller is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newComptroller The address of the new comptroller contract.\n function setComptroller(ISablierV2Comptroller newComptroller) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Comptroller.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\n\n/// @title ISablierV2Controller\n/// @notice This contract is in charge of the Sablier V2 protocol configuration, handling such values as the\n/// protocol fees.\ninterface ISablierV2Comptroller is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin sets a new flash fee.\n /// @param admin The address of the contract admin.\n /// @param oldFlashFee The old flash fee, denoted as a fixed-point number.\n /// @param newFlashFee The new flash fee, denoted as a fixed-point number.\n event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);\n\n /// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.\n /// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.\n event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);\n\n /// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset to toggle.\n /// @param newFlag Whether the ERC-20 asset can be flash loaned.\n event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.\n ///\n /// @dev Notes:\n /// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},\n /// which calculates the fee amount for a specified flash loan amount.\n /// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.\n function flashFee() external view returns (UD60x18 fee);\n\n /// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.\n /// @param token The contract address of the ERC-20 asset to check.\n function isFlashAsset(IERC20 token) external view returns (bool result);\n\n /// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.\n /// @param asset The contract address of the ERC-20 asset to query.\n /// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.\n function protocolFees(IERC20 asset) external view returns (UD60x18 fee);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.\n ///\n /// @dev Emits a {SetFlashFee} event.\n ///\n /// Notes:\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.\n function setFlashFee(UD60x18 newFlashFee) external;\n\n /// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.\n ///\n /// @dev Emits a {SetProtocolFee} event.\n ///\n /// Notes:\n /// - The fee is not denoted in units of the asset's decimals; it is a fixed-point number. Refer to the\n /// PRBMath documentation for more detail on the logic of UD60x18.\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset to update the fee for.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.\n function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;\n\n /// @notice Toggles the flash loanability of an ERC-20 asset.\n ///\n /// @dev Emits a {ToggleFlashAsset} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the admin.\n ///\n /// @param asset The address of the ERC-20 asset to toggle.\n function toggleFlashAsset(IERC20 asset) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Lockup.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\nimport { Lockup } from \"../types/DataTypes.sol\";\nimport { ISablierV2Base } from \"./ISablierV2Base.sol\";\nimport { ISablierV2NFTDescriptor } from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup streaming contracts.\ninterface ISablierV2Lockup is\n ISablierV2Base, // 1 inherited component\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The id of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The id of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The id of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset used for streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getEndTime(uint256 streamId) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream id for the query.\n function getRecipient(uint256 streamId) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStartTime(uint256 streamId) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isTransferable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Counter for stream ids, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @param streamId The stream id for the query.\n function statusOf(uint256 streamId) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The id of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The id of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The ids of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The id of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract\n /// and `msg.sender` is either the sender or an approved operator.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `msg.sender` must be the stream's sender, the stream's recipient or an approved third party.\n /// - `to` must be the recipient if `msg.sender` is the stream's sender.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n function withdrawMax(uint256 streamId, address to) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The id of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n function withdrawMaxAndTransfer(uint256 streamId, address newRecipient) external;\n\n /// @notice Withdraws assets from streams to the provided address `to`.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - All requirements from {withdraw} must be met for each stream.\n /// - There must be an equal number of `streamIds` and `amounts`.\n ///\n /// @param streamIds The ids of the streams to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport { Lockup, LockupLinear } from \"../types/DataTypes.sol\";\nimport { ISablierV2Lockup } from \"./ISablierV2Lockup.sol\";\n\n/// @title ISablierV2LockupLinear\n/// @notice Creates and manages Lockup streams with linear streaming functions.\ninterface ISablierV2LockupLinear is ISablierV2Lockup {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is created.\n /// @param streamId The id of the newly created stream.\n /// @param funder The address which funded the stream.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param recipient The address receiving the assets.\n /// @param amounts Struct containing (i) the deposit amount, (ii) the protocol fee amount, and (iii) the\n /// broker fee amount, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Boolean indicating whether the stream will be cancelable or not.\n /// @param transferable Boolean indicating whether the stream NFT is transferable or not.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker The address of the broker who has helped create the stream, e.g. a front-end website.\n event CreateLockupLinearStream(\n uint256 streamId,\n address funder,\n address indexed sender,\n address indexed recipient,\n Lockup.CreateAmounts amounts,\n IERC20 indexed asset,\n bool cancelable,\n bool transferable,\n LockupLinear.Range range,\n address broker\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the stream's cliff time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);\n\n /// @notice Retrieves the stream's range, which is a struct containing (i) the stream's start time, (ii) cliff\n /// time, and (iii) end time, all as Unix timestamps.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);\n\n /// @notice Retrieves the stream entity.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n ///\n /// When the stream is warm, the streaming function is:\n ///\n /// $$\n /// f(x) = x * d + c\n /// $$\n ///\n /// Where:\n ///\n /// - $x$ is the elapsed time divided by the stream's total duration.\n /// - $d$ is the deposited amount.\n /// - $c$ is the cliff amount.\n ///\n /// Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Creates a stream by setting the start time to `block.timestamp`, and the end time to\n /// the sum of `block.timestamp` and `params.durations.total`. The stream is funded by `msg.sender` and is wrapped\n /// in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Requirements:\n /// - All requirements in {createWithRange} must be met for the calculated parameters.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithDurations(LockupLinear.CreateWithDurations calldata params)\n external\n returns (uint256 streamId);\n\n /// @notice Creates a stream with the provided start time and end time as the range. The stream is\n /// funded by `msg.sender` and is wrapped in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Notes:\n /// - As long as the times are ordered, it is not an error for the start or the cliff time to be in the past.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `params.totalAmount` must be greater than zero.\n /// - If set, `params.broker.fee` must not be greater than `MAX_FEE`.\n /// - `params.range.start` must be less than or equal to `params.range.cliff`.\n /// - `params.range.cliff` must be less than `params.range.end`.\n /// - `params.range.end` must be in the future.\n /// - `params.recipient` must not be the zero address.\n /// - `msg.sender` must have allowed this contract to spend at least `params.totalAmount` assets.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2NFTDescriptor.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The id of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);\n}\n" - }, - "@sablier/v2-core/src/types/DataTypes.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD2x18 } from \"@prb/math/src/UD2x18.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units\n /// of the asset's decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in\n /// the same slot saves gas.\n /// @param deposited The initial amount deposited in the stream, net of fees.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating the deposit amount, the protocol fee amount, and the broker fee amount,\n /// all denoted in units of the asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param protocolFee The protocol fee amount.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 protocolFee;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value STREAMING Active stream where assets are currently being streamed.\n /// @custom:value SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING, // value 0\n STREAMING, // value 1\n SETTLED, // value 2\n CANCELED, // value 3\n DEPLETED // value 4\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithDeltas} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments with deltas used to compose the custom streaming curve. Milestones are calculated by\n /// starting from `block.timestamp` and adding each delta to the previous milestone.\n struct CreateWithDeltas {\n address sender;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n SegmentWithDelta[] segments;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithMilestones}\n /// function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments used to compose the custom streaming curve.\n struct CreateWithMilestones {\n address sender;\n uint40 startTime;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Range {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param milestone The Unix timestamp indicating this segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 milestone;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDeltas}.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param delta The time difference in seconds between this segment and the previous one.\n struct SegmentWithDelta {\n uint128 amount;\n UD2x18 exponent;\n uint40 delta;\n }\n\n /// @notice Lockup Dynamic stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n /// @param segments Segments used to compose the custom streaming curve.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n // slots [4..n]\n Segment[] segments;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithRange} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithRange {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Range range;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end.\n /// @param end The Unix timestamp for the stream's end.\n struct Range {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n /// @notice Lockup Linear stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cliffTime The Unix timestamp indicating the cliff period's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 cliffTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n" - }, - "contracts/interfaces/IDexAggregator.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IDexAggregator {\n struct FormattedOffer {\n uint256[] amounts;\n address[] adapters;\n address[] path;\n uint256 gasEstimate;\n }\n\n struct Trade {\n uint256 amountIn;\n uint256 amountOut;\n address[] path;\n address[] adapters;\n }\n\n function findBestPath(\n uint256 _amountIn,\n address _tokenIn,\n address _tokenOut,\n uint256 _maxSteps\n ) external view returns (FormattedOffer memory);\n\n function swapNoSplitFromAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external payable;\n\n function swapNoSplitToAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n\n function swapNoSplit(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n}\n" - }, - "contracts/interfaces/IMemeFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface ITokenFactory {}\n" - }, - "contracts/interfaces/INonfungiblePositionManager.sol": { - "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Non-fungible token for positions\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\n/// and authorized.\ninterface INonfungiblePositionManager {\n struct MintParams {\n address token0;\n address token1;\n uint24 fee;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n address recipient;\n uint256 deadline;\n }\n\n /// @notice Creates a new position wrapped in a NFT\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\n /// a method does not exist, i.e. the pool is assumed to be initialized.\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\n /// @return tokenId The ID of the token that represents the minted position\n /// @return liquidity The amount of liquidity for this position\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\n function mint(\n MintParams calldata params\n )\n external\n payable\n returns (\n uint256 tokenId,\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n}\n" - }, - "contracts/interfaces/IStratosphere.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IStratosphere {\n function tokenIdOf(address _owner) external view returns (uint256);\n\n function mint() external returns (uint256);\n}\n" - }, - "contracts/interfaces/IVaporDEXFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n" - }, - "contracts/interfaces/IVaporDEXRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXRouter {\n function factory() external view returns (address);\n\n function WETH() external view returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n" - }, - "contracts/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ERC20Permit} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IStratosphere} from \"./interfaces/IStratosphere.sol\";\n\nerror Token__MissingLiquidityPool();\nerror Token__ExceedsMaximumHolding();\nerror Token__TradingNotStarted();\nerror Token__NonStratosphereNFTHolder();\nerror Token__BotDetected();\n\ncontract Token is ERC20, ERC20Permit, Ownable {\n address public liquidityPool;\n address public immutable dexAggregator;\n address public immutable dexAdapter;\n uint256 public immutable maxHoldingAmount;\n uint256 public immutable tradingStartsAt;\n IStratosphere public immutable stratosphere;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _supply,\n address _stratosphereAddress,\n address _owner,\n uint256 _tradingStartsAt,\n address _dexAggregator,\n address _dexAdapter\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\n stratosphere = IStratosphere(_stratosphereAddress);\n _mint(msg.sender, _supply);\n maxHoldingAmount = _percentage(_supply, 100); // 1% of total supply\n tradingStartsAt = _tradingStartsAt;\n dexAggregator = _dexAggregator;\n dexAdapter = _dexAdapter;\n }\n\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\n if (_liquidityPool == address(0)) {\n revert Token__MissingLiquidityPool();\n }\n liquidityPool = _liquidityPool;\n }\n\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\n function _update(\n address from,\n address to,\n uint256 value\n ) internal virtual override {\n super._update(from, to, value);\n uint256 _tradingStartsAt = tradingStartsAt;\n\n if (liquidityPool == address(0)) {\n require(\n from == owner() || to == owner(),\n \"Patience - Trading Not Started Yet!\"\n );\n return;\n }\n\n if (block.timestamp < _tradingStartsAt) {\n revert Token__TradingNotStarted();\n }\n\n uint256 _secondsSinceTradingStarted = block.timestamp -\n _tradingStartsAt;\n\n if (_secondsSinceTradingStarted > 24 hours) {\n return;\n }\n\n if (_secondsSinceTradingStarted < 1 hours) {\n _enforceAntiWhale(to, value);\n if (!(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to))) {\n revert Token__NonStratosphereNFTHolder();\n }\n } else if (_secondsSinceTradingStarted < 24 hours) {\n _enforceAntiWhale(to, value);\n }\n }\n\n function _enforceAntiWhale(address to, uint256 value) internal view {\n if (to != liquidityPool) {\n uint256 newBalance = balanceOf(to) + value;\n if (newBalance > maxHoldingAmount) {\n revert Token__ExceedsMaximumHolding();\n }\n }\n }\n\n function _isStratosphereMemberOrAdmin(address _address) internal view returns (bool pass) {\n if (_address == dexAggregator || _address == dexAdapter || stratosphere.tokenIdOf(_address) != 0 ||\n _address == liquidityPool) {\n pass = true;\n }\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n}\n" - }, - "contracts/TokenFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IVaporDEXFactory} from \"./interfaces/IVaporDEXFactory.sol\";\nimport {IVaporDEXRouter} from \"./interfaces/IVaporDEXRouter.sol\";\nimport {Token} from \"./Token.sol\";\nimport {ISablierV2LockupLinear} from \"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\";\nimport {LockupLinear} from \"@sablier/v2-core/src/types/DataTypes.sol\";\nimport {IDexAggregator} from \"./interfaces/IDexAggregator.sol\";\nimport {INonfungiblePositionManager} from \"./interfaces/INonfungiblePositionManager.sol\";\n\nerror TokenFactory__WrongConstructorArguments();\nerror TokenFactory__LiquidityLockedOrDepleted();\nerror TokenFactory__Unauthorized();\nerror TokenFactory__ZeroAddress();\nerror TokenFactory__WrongLaunchArguments();\nerror TokenFactory__InsufficientBalance();\nerror TokenFactory__Invalid();\nerror TokenFactory__TranferFailed(address);\nerror TokenFactory__NotEnoughLiquidity();\nerror TokenFactory__MinimumLockDuration();\n\n/// @title TokenFactory\n/// @author Roy & Jose\n/// @notice This contract is used to launch new tokens and create liquidity for them\n/// @dev Utilizes 'Sablier' for liquidity locking\n\ncontract TokenFactory is Ownable {\n //////////////\n /// EVENTS ///\n //////////////\n\n event TokenLaunched(\n address indexed _tokenAddress,\n address indexed _pairAddress,\n bool _liquidityBurned\n );\n\n event StreamCreated(uint256 indexed _streamId);\n event LiquidityBurned(\n address indexed pair,\n address indexed _burner,\n uint256 _amount\n );\n event LiquidityTokensUnlocked(\n address indexed _pairAddress,\n address indexed _receiver\n );\n event LiquidityTransferred(\n address indexed _pairAddress,\n address indexed _to\n );\n event LaunchFeeUpdated(uint256 _newFee);\n event SlippageUpdated(uint256 _newSlippage);\n event MinimumLiquidityETHUpdated(uint256 _newFee);\n event MinimumLockDurationUpdated(uint40 _newFee);\n event VaporDEXAdapterUpdated(address _newAdapter);\n event AccumulatedFeesWithdrawn(address _to, uint256 _amount);\n\n ///////////////\n /// STORAGE ///\n ///////////////\n address private immutable factory;\n address private immutable router;\n address private immutable stratosphere;\n IDexAggregator private immutable vaporDexAggregator;\n INonfungiblePositionManager private immutable nonFungiblePositionManager;\n IERC20 private immutable WETH;\n IERC20 private immutable USDC;\n IERC20 private immutable VAPE;\n address private vaporDexAdapter;\n address private teamMultisig;\n uint256 private launchFee;\n uint256 public minLiquidityETH;\n uint256 public slippage;\n uint40 public minLockDuration;\n\n // Sablier\n ISablierV2LockupLinear private immutable sablier;\n // Mapping to store the streamId for each pair and lp owner\n mapping(address => mapping(address => uint256)) private liquidityLocks;\n\n /**\n * @dev TokenFactory constructor initializes the contract with required parameters.\n * @param owner Address of the contract owner.\n * @param routerAddress Address of the VaporDEXRouter contract.\n * @param stratosphereAddress Address of the Stratosphere contract.\n * @param vaporDexAggregator Address of the VaporDEX aggregator.\n * @param vaporDexAdapter Address of the VaporDEX adapter.\n * @param usdc Address of the USDC token.\n * @param vape Address of the VAPE token.\n * @param launchFee Launch fee in USDC.\n * @param uint256 minLiquidityETH;\n * @param uint40 minLockDuration;\n * @param sablier Address of the Sablier contract.\n * @param nonFungiblePositionManager Uni v3 NFT Position Manager\n * @param teamMultisig Multisig address\n * @param slippage\n */\n struct DeployArgs {\n address owner;\n address routerAddress;\n address stratosphereAddress;\n address vaporDexAggregator;\n address vaporDexAdapter;\n address usdc;\n address vape;\n uint256 launchFee;\n uint256 minLiquidityETH;\n uint40 minLockDuration;\n address sablier;\n address nonFungiblePositionManager;\n address teamMultisig;\n uint256 slippage;\n }\n\n /////////////////////////\n ////// CONSTRUCTOR /////\n ////////////////////////\n\n constructor(DeployArgs memory args) Ownable(args.owner) {\n // Check for valid constructor arguments\n if (\n args.owner == address(0) ||\n args.routerAddress == address(0) ||\n args.stratosphereAddress == address(0) ||\n args.vaporDexAggregator == address(0) ||\n args.vaporDexAdapter == address(0) ||\n args.usdc == address(0) ||\n args.launchFee == 0 ||\n args.sablier == address(0) ||\n args.minLiquidityETH == 0 ||\n args.minLockDuration == 0\n ) {\n revert TokenFactory__WrongConstructorArguments();\n }\n\n // Initialize variables\n slippage = args.slippage;\n router = args.routerAddress;\n IVaporDEXRouter _router = IVaporDEXRouter(args.routerAddress);\n factory = _router.factory();\n WETH = IERC20(_router.WETH());\n USDC = IERC20(args.usdc);\n VAPE = IERC20(args.vape);\n minLiquidityETH = args.minLiquidityETH;\n minLockDuration = args.minLockDuration;\n\n stratosphere = args.stratosphereAddress;\n vaporDexAggregator = IDexAggregator(args.vaporDexAggregator);\n vaporDexAdapter = args.vaporDexAdapter;\n launchFee = args.launchFee;\n sablier = ISablierV2LockupLinear(args.sablier);\n nonFungiblePositionManager = INonfungiblePositionManager(\n args.nonFungiblePositionManager\n );\n teamMultisig = args.teamMultisig;\n }\n\n /**\n * @dev Launches a new token with specified parameters.\n * @param _name Name of the token.\n * @param _symbol Symbol of the token.\n * @param _totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param lockDuration Number of days to lock liquidity for.\n * @param _burnLiquidity Flag indicating whether to burn liquidity or lock it.\n * @return _pair Address of the created token pair.\n * @return _tokenAddress Address of the launched token.\n * @return streamId Stream ID if liquidity is locked, otherwise 0.\n */\n\n function launch(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint256 _tradingStartsAt,\n uint40 lockDuration,\n bool _burnLiquidity\n )\n external\n payable\n returns (address _pair, address _tokenAddress, uint256 streamId)\n {\n uint256 value = msg.value;\n if (value < minLiquidityETH) {\n revert TokenFactory__NotEnoughLiquidity();\n }\n // Step 0: Transfer Fee\n _transferLaunchFee(msg.sender);\n\n // Step 1: Create the token\n Token _token = _createToken(\n _name,\n _symbol,\n _totalSupply,\n _tradingStartsAt,\n address(vaporDexAggregator),\n vaporDexAdapter\n );\n _tokenAddress = address(_token);\n\n // Step 2: Create the pair\n IVaporDEXFactory _factory = IVaporDEXFactory(factory);\n _pair = _factory.createPair(_tokenAddress, address(WETH));\n _token.approve(router, _totalSupply);\n _token.approve(_pair, _totalSupply);\n\n // Step 2: Add Liquidity\n IVaporDEXRouter _router = IVaporDEXRouter(router);\n _router.addLiquidityETH{value: value}(\n _tokenAddress,\n _totalSupply,\n _totalSupply,\n value,\n address(this),\n block.timestamp + 10 minutes\n );\n // Step 3: Get the pair address\n _pair = IVaporDEXFactory(factory).getPair(_tokenAddress, address(WETH));\n if (_pair == address(0)) {\n revert TokenFactory__ZeroAddress();\n }\n // Step 4: Set the LP address in the token\n _token.setLiquidityPool(_pair);\n // Step 5: Renounce ownership of the token\n _token.renounceOwnership();\n\n // Step 6: Lock Or Burn Liquidity\n\n IERC20 _lpToken = IERC20(_pair);\n\n if (_burnLiquidity) {\n // Burn Liquidity\n _lpToken.transfer(address(0), _lpToken.balanceOf(address(this)));\n emit LiquidityBurned(\n _pair,\n msg.sender,\n _lpToken.balanceOf(address(this))\n );\n } else {\n if (lockDuration < minLockDuration) {\n revert TokenFactory__MinimumLockDuration();\n }\n _lpToken.approve(\n address(sablier),\n _lpToken.balanceOf(address(this))\n );\n // Lock Liquidity\n // SablierV2\n LockupLinear.CreateWithDurations memory params;\n\n // Declare the function parameters\n params.sender = address(this); // The sender will be able to cancel the stream\n params.recipient = msg.sender; // The recipient of the streamed assets\n params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees\n params.asset = _lpToken; // The streaming asset\n params.cancelable = false; // Whether the stream will be cancelable or not\n params.transferable = true; // Whether the stream will be transferrable or not\n params.durations = LockupLinear.Durations({\n cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period\n total: lockDuration * 1 days\n });\n\n // Create the stream\n streamId = sablier.createWithDurations(params);\n liquidityLocks[msg.sender][_pair] = streamId;\n\n emit StreamCreated(streamId);\n }\n\n // Step 7: Buy VAPE with USDC on VaporDEXAggregator\n\n _buyVapeWithUsdc(launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee\n\n // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2\n\n _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract\n\n emit TokenLaunched(_tokenAddress, _pair, _burnLiquidity);\n }\n\n /**\n * @dev Unlocks liquidity tokens for the specified pair and recipient.\n * @param _pair Address of the token pair.\n * @param _receiver Address of the recipient of unlocked tokens.\n * @notice It is recommended to direct the user to Sablier UI for better error handling.\n */\n function unlockLiquidityTokens(address _pair, address _receiver) external {\n if (_receiver == address(0)) {\n revert TokenFactory__ZeroAddress();\n }\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n\n if (streamId == 0) {\n revert TokenFactory__Unauthorized();\n }\n\n uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n revert TokenFactory__LiquidityLockedOrDepleted();\n }\n\n sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier\n\n emit LiquidityTokensUnlocked(_pair, _receiver);\n }\n\n /**\n * @dev Transfers the locked liquidity to the specified recipient for the given pair.\n * @param _pair Address of the token pair.\n * @param _to Address of the recipient.\n */\n function transferLock(address _pair, address _to) external {\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n if (\n streamId == 0 ||\n _to == address(0) ||\n sablier.isTransferable(streamId) == false\n ) {\n revert TokenFactory__Unauthorized();\n }\n\n liquidityLocks[_to][_pair] = streamId;\n liquidityLocks[msg.sender][_pair] = 0;\n\n sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier\n\n emit LiquidityTransferred(_pair, _to);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _liquidity New liquidity.\n */\n\n function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner {\n if (_liquidity == 0) {\n revert TokenFactory__Invalid();\n }\n minLiquidityETH = _liquidity;\n emit MinimumLiquidityETHUpdated(_liquidity);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _slippage New lock duration in days.\n */\n\n function setSlippage(uint256 _slippage) external onlyOwner {\n slippage = _slippage;\n emit SlippageUpdated(_slippage);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _lockDuration New lock duration in days.\n */\n\n function setMinLockDuration(uint40 _lockDuration) external onlyOwner {\n if (_lockDuration == 0) {\n revert TokenFactory__Invalid();\n }\n minLockDuration = _lockDuration;\n emit MinimumLockDurationUpdated(_lockDuration);\n }\n\n /**\n * @dev Sets the launch fee for creating new tokens.\n * @param _launchFee New launch fee in USDC.\n */\n\n function setLaunchFee(uint256 _launchFee) external onlyOwner {\n if (_launchFee == 0) {\n revert TokenFactory__Invalid();\n }\n launchFee = _launchFee;\n emit LaunchFeeUpdated(_launchFee);\n }\n\n /**\n * @dev Sets the VaporDEX adapter address.\n * @param _vaporDexAdapter New VaporDEX adapter address.\n */\n\n function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner {\n if (\n _vaporDexAdapter == vaporDexAdapter ||\n _vaporDexAdapter == address(0)\n ) {\n revert TokenFactory__Invalid();\n }\n vaporDexAdapter = _vaporDexAdapter;\n emit VaporDEXAdapterUpdated(_vaporDexAdapter);\n }\n\n /**\n * @dev Withdraws any remaining USDC fees to the specified address.\n * @param _to Address to which the remaining fees are withdrawn.\n */\n\n function withdrawFee(address _to) external onlyOwner {\n if (_to == address(0)) {\n revert TokenFactory__ZeroAddress();\n }\n IERC20 _usdc = IERC20(USDC);\n _usdc.transfer(_to, _usdc.balanceOf(address(this)));\n emit AccumulatedFeesWithdrawn(_to, _usdc.balanceOf(address(this)));\n }\n\n /**\n * @dev Creates a new Token contract with specified parameters.\n * @param name Name of the token.\n * @param symbol Symbol of the token.\n * @param totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param dexAggregator Address of the decentralized exchange aggregator.\n * @param dexAdapter Address of the decentralized exchange adapter.\n * @return _token Instance of the created Token contract.\n */\n function _createToken(\n string memory name,\n string memory symbol,\n uint256 totalSupply,\n uint256 _tradingStartsAt,\n address dexAggregator,\n address dexAdapter\n ) internal returns (Token _token) {\n if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) {\n revert TokenFactory__WrongLaunchArguments();\n }\n _token = new Token(\n name,\n symbol,\n totalSupply,\n stratosphere,\n address(this),\n _tradingStartsAt,\n dexAggregator,\n dexAdapter\n );\n }\n\n /**\n * @dev Transfers the launch fee in USDC from the sender.\n * @param _from Address from which the launch fee is transferred.\n */\n\n function _transferLaunchFee(address _from) internal {\n IERC20 _usdc = IERC20(USDC);\n if (_usdc.balanceOf(_from) < launchFee) {\n revert TokenFactory__InsufficientBalance();\n }\n bool isSuccess = _usdc.transferFrom(_from, address(this), launchFee);\n if (!isSuccess) {\n revert TokenFactory__TranferFailed(_from);\n }\n }\n\n /**\n * @dev Buys VAPE with USDC on VaporDEXAggregator\n * @param amountIn Amount of USDC to be used for buying VAPE.\n */\n\n function _buyVapeWithUsdc(uint256 amountIn) internal {\n USDC.approve(address(vaporDexAggregator), amountIn);\n\n IDexAggregator.FormattedOffer memory offer = vaporDexAggregator\n .findBestPath(\n amountIn,\n address(USDC),\n address(VAPE),\n 1 // can be changed to 3\n );\n IDexAggregator.Trade memory trade;\n trade.amountIn = amountIn;\n trade.amountOut = offer.amounts[offer.amounts.length - 1];\n trade.path = offer.path;\n trade.adapters = offer.adapters;\n vaporDexAggregator.swapNoSplit(trade, address(this), 0);\n }\n\n /**\n * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2.\n * @notice Uses the balance of VAPE and USDC in the contract.\n */\n\n function _addLiquidityVapeUsdc() internal {\n uint256 amountInUSDC = USDC.balanceOf(address(this));\n uint256 amountInVAPE = VAPE.balanceOf(address(this));\n USDC.approve(address(nonFungiblePositionManager), amountInUSDC);\n VAPE.approve(address(nonFungiblePositionManager), amountInVAPE);\n INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager\n .MintParams({\n token0: address(VAPE),\n token1: address(USDC),\n fee: 3000,\n tickLower: -887220, // full range\n tickUpper: 887220, // full range\n amount0Desired: amountInVAPE,\n amount1Desired: amountInUSDC,\n amount0Min: amountInVAPE - _percentage(amountInVAPE, slippage), // 2% slippage\n amount1Min: amountInUSDC - _percentage(amountInUSDC, slippage), // 2% slippage\n recipient: teamMultisig,\n deadline: block.timestamp + 2 minutes\n });\n nonFungiblePositionManager.mint(mintParams);\n\n // Q: What checks should be done with the return values?\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n\n // Getters\n\n /**\n * @dev Returns the launch fee.\n * @return uint256 The launch fee.\n */\n function getLaunchFee() external view returns (uint256) {\n return launchFee;\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDexAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the VaporDEX router.\n * @return address The address of the VaporDEX router.\n */\n function getVaporDEXRouter() external view returns (address) {\n return router;\n }\n\n /**\n * @dev Returns the address of the VaporDEX factory.\n * @return address The address of the VaporDEX factory.\n */\n function getVaporDEXFactory() external view returns (address) {\n return factory;\n }\n\n /**\n * @dev Returns the address of the Stratosphere contract.\n * @return address The address of the Stratosphere contract.\n */\n function getStratosphere() external view returns (address) {\n return stratosphere;\n }\n\n /**\n * @dev Returns the address of the VaporDEX aggregator.\n * @return address The address of the VaporDEX aggregator.\n */\n function getVaporDexAggregator() external view returns (address) {\n return address(vaporDexAggregator);\n }\n\n /**\n * @dev Returns the address of the USDC token.\n * @return address The address of the USDC token.\n */\n function getUSDC() external view returns (address) {\n return address(USDC);\n }\n\n /**\n * @dev Returns the address of the VAPE token.\n * @return address The address of the VAPE token.\n */\n function getVAPE() external view returns (address) {\n return address(VAPE);\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDEXAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the team multisig wallet.\n * @return address The address of the team multisig wallet.\n */\n function getTeamMultisig() external view returns (address) {\n return teamMultisig;\n }\n\n /**\n * @dev Returns the address of the Sablier contract.\n * @return address The address of the Sablier contract.\n */\n function getSablier() external view returns (address) {\n return address(sablier);\n }\n\n /**\n * @dev Returns the address of the NonFungiblePositionManager contract.\n * @return address The address of the NonFungiblePositionManager contract.\n */\n function getNonFungiblePositionManager() external view returns (address) {\n return address(nonFungiblePositionManager);\n }\n\n /**\n * @dev Returns the liquidity lock for the specified pair and owner.\n * @param _pair Address of the token pair.\n * @param _owner Address of the owner.\n * @return uint256 Stream ID for the liquidity lock.\n */\n\n function getLiquidityLock(\n address _pair,\n address _owner\n ) external view returns (uint256) {\n return liquidityLocks[_owner][_pair];\n }\n}\n" - } - }, - "settings": { - "evmVersion": "paris", - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/avalancheFuji/solcInputs/b6cee9c8c6f10c70a8884c60e4e6302c.json b/deployments/avalancheFuji/solcInputs/b6cee9c8c6f10c70a8884c60e4e6302c.json deleted file mode 100644 index b150cbb..0000000 --- a/deployments/avalancheFuji/solcInputs/b6cee9c8c6f10c70a8884c60e4e6302c.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" - }, - "@openzeppelin/contracts/interfaces/IERC5267.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n bytes32 private constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Permit deadline has expired.\n */\n error ERC2612ExpiredSignature(uint256 deadline);\n\n /**\n * @dev Mismatched signature.\n */\n error ERC2612InvalidSigner(address signer, address owner);\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @inheritdoc IERC20Permit\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > deadline) {\n revert ERC2612ExpiredSignature(deadline);\n }\n\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n if (signer != owner) {\n revert ERC2612InvalidSigner(signer, owner);\n }\n\n _approve(owner, spender, value);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n return super.nonces(owner);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparatorV4();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n * {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the address zero.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Nonces.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/ShortStrings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" - }, - "@prb/math/src/Common.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" - }, - "@prb/math/src/sd1x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd1x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n" - }, - "@prb/math/src/sd1x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" - }, - "@prb/math/src/sd1x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" - }, - "@prb/math/src/sd59x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd59x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" - }, - "@prb/math/src/sd59x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" - }, - "@prb/math/src/sd59x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/sd59x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" - }, - "@prb/math/src/sd59x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" - }, - "@prb/math/src/UD2x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud2x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud2x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n" - }, - "@prb/math/src/ud2x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" - }, - "@prb/math/src/ud2x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" - }, - "@prb/math/src/UD60x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud60x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud60x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" - }, - "@prb/math/src/ud60x18/Conversions.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" - }, - "@prb/math/src/ud60x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" - }, - "@prb/math/src/ud60x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/ud60x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" - }, - "@prb/math/src/ud60x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" - }, - "@sablier/v2-core/src/interfaces/IAdminable.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Base.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\nimport { ISablierV2Comptroller } from \"./ISablierV2Comptroller.sol\";\n\n/// @title ISablierV2Base\n/// @notice Base logic for all Sablier V2 streaming contracts.\ninterface ISablierV2Base is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin claims all protocol revenues accrued for a particular ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the protocol revenues have been claimed for.\n /// @param protocolRevenues The amount of protocol revenues claimed, denoted in units of the asset's decimals.\n event ClaimProtocolRevenues(address indexed admin, IERC20 indexed asset, uint128 protocolRevenues);\n\n /// @notice Emitted when the admin sets a new comptroller contract.\n /// @param admin The address of the contract admin.\n /// @param oldComptroller The address of the old comptroller contract.\n /// @param newComptroller The address of the new comptroller contract.\n event SetComptroller(\n address indexed admin, ISablierV2Comptroller oldComptroller, ISablierV2Comptroller newComptroller\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the maximum fee that can be charged by the protocol or a broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_FEE() external view returns (UD60x18);\n\n /// @notice Retrieves the address of the comptroller contract, responsible for the Sablier V2 protocol\n /// configuration.\n function comptroller() external view returns (ISablierV2Comptroller);\n\n /// @notice Retrieves the protocol revenues accrued for the provided ERC-20 asset, in units of the asset's\n /// decimals.\n /// @param asset The contract address of the ERC-20 asset to query.\n function protocolRevenues(IERC20 asset) external view returns (uint128 revenues);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Claims all accumulated protocol revenues for the provided ERC-20 asset.\n ///\n /// @dev Emits a {ClaimProtocolRevenues} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset for which to claim protocol revenues.\n function claimProtocolRevenues(IERC20 asset) external;\n\n /// @notice Assigns a new comptroller contract responsible for the protocol configuration.\n ///\n /// @dev Emits a {SetComptroller} event.\n ///\n /// Notes:\n /// - Does not revert if the comptroller is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newComptroller The address of the new comptroller contract.\n function setComptroller(ISablierV2Comptroller newComptroller) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Comptroller.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\n\n/// @title ISablierV2Controller\n/// @notice This contract is in charge of the Sablier V2 protocol configuration, handling such values as the\n/// protocol fees.\ninterface ISablierV2Comptroller is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin sets a new flash fee.\n /// @param admin The address of the contract admin.\n /// @param oldFlashFee The old flash fee, denoted as a fixed-point number.\n /// @param newFlashFee The new flash fee, denoted as a fixed-point number.\n event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);\n\n /// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.\n /// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.\n event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);\n\n /// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset to toggle.\n /// @param newFlag Whether the ERC-20 asset can be flash loaned.\n event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.\n ///\n /// @dev Notes:\n /// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},\n /// which calculates the fee amount for a specified flash loan amount.\n /// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.\n function flashFee() external view returns (UD60x18 fee);\n\n /// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.\n /// @param token The contract address of the ERC-20 asset to check.\n function isFlashAsset(IERC20 token) external view returns (bool result);\n\n /// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.\n /// @param asset The contract address of the ERC-20 asset to query.\n /// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.\n function protocolFees(IERC20 asset) external view returns (UD60x18 fee);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.\n ///\n /// @dev Emits a {SetFlashFee} event.\n ///\n /// Notes:\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.\n function setFlashFee(UD60x18 newFlashFee) external;\n\n /// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.\n ///\n /// @dev Emits a {SetProtocolFee} event.\n ///\n /// Notes:\n /// - The fee is not denoted in units of the asset's decimals; it is a fixed-point number. Refer to the\n /// PRBMath documentation for more detail on the logic of UD60x18.\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset to update the fee for.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.\n function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;\n\n /// @notice Toggles the flash loanability of an ERC-20 asset.\n ///\n /// @dev Emits a {ToggleFlashAsset} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the admin.\n ///\n /// @param asset The address of the ERC-20 asset to toggle.\n function toggleFlashAsset(IERC20 asset) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Lockup.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\nimport { Lockup } from \"../types/DataTypes.sol\";\nimport { ISablierV2Base } from \"./ISablierV2Base.sol\";\nimport { ISablierV2NFTDescriptor } from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup streaming contracts.\ninterface ISablierV2Lockup is\n ISablierV2Base, // 1 inherited component\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The id of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The id of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The id of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset used for streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getEndTime(uint256 streamId) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream id for the query.\n function getRecipient(uint256 streamId) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStartTime(uint256 streamId) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isTransferable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Counter for stream ids, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @param streamId The stream id for the query.\n function statusOf(uint256 streamId) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The id of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The id of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The ids of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The id of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract\n /// and `msg.sender` is either the sender or an approved operator.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `msg.sender` must be the stream's sender, the stream's recipient or an approved third party.\n /// - `to` must be the recipient if `msg.sender` is the stream's sender.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n function withdrawMax(uint256 streamId, address to) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The id of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n function withdrawMaxAndTransfer(uint256 streamId, address newRecipient) external;\n\n /// @notice Withdraws assets from streams to the provided address `to`.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - All requirements from {withdraw} must be met for each stream.\n /// - There must be an equal number of `streamIds` and `amounts`.\n ///\n /// @param streamIds The ids of the streams to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport { Lockup, LockupLinear } from \"../types/DataTypes.sol\";\nimport { ISablierV2Lockup } from \"./ISablierV2Lockup.sol\";\n\n/// @title ISablierV2LockupLinear\n/// @notice Creates and manages Lockup streams with linear streaming functions.\ninterface ISablierV2LockupLinear is ISablierV2Lockup {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is created.\n /// @param streamId The id of the newly created stream.\n /// @param funder The address which funded the stream.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param recipient The address receiving the assets.\n /// @param amounts Struct containing (i) the deposit amount, (ii) the protocol fee amount, and (iii) the\n /// broker fee amount, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Boolean indicating whether the stream will be cancelable or not.\n /// @param transferable Boolean indicating whether the stream NFT is transferable or not.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker The address of the broker who has helped create the stream, e.g. a front-end website.\n event CreateLockupLinearStream(\n uint256 streamId,\n address funder,\n address indexed sender,\n address indexed recipient,\n Lockup.CreateAmounts amounts,\n IERC20 indexed asset,\n bool cancelable,\n bool transferable,\n LockupLinear.Range range,\n address broker\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the stream's cliff time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);\n\n /// @notice Retrieves the stream's range, which is a struct containing (i) the stream's start time, (ii) cliff\n /// time, and (iii) end time, all as Unix timestamps.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);\n\n /// @notice Retrieves the stream entity.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n ///\n /// When the stream is warm, the streaming function is:\n ///\n /// $$\n /// f(x) = x * d + c\n /// $$\n ///\n /// Where:\n ///\n /// - $x$ is the elapsed time divided by the stream's total duration.\n /// - $d$ is the deposited amount.\n /// - $c$ is the cliff amount.\n ///\n /// Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Creates a stream by setting the start time to `block.timestamp`, and the end time to\n /// the sum of `block.timestamp` and `params.durations.total`. The stream is funded by `msg.sender` and is wrapped\n /// in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Requirements:\n /// - All requirements in {createWithRange} must be met for the calculated parameters.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithDurations(LockupLinear.CreateWithDurations calldata params)\n external\n returns (uint256 streamId);\n\n /// @notice Creates a stream with the provided start time and end time as the range. The stream is\n /// funded by `msg.sender` and is wrapped in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Notes:\n /// - As long as the times are ordered, it is not an error for the start or the cliff time to be in the past.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `params.totalAmount` must be greater than zero.\n /// - If set, `params.broker.fee` must not be greater than `MAX_FEE`.\n /// - `params.range.start` must be less than or equal to `params.range.cliff`.\n /// - `params.range.cliff` must be less than `params.range.end`.\n /// - `params.range.end` must be in the future.\n /// - `params.recipient` must not be the zero address.\n /// - `msg.sender` must have allowed this contract to spend at least `params.totalAmount` assets.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2NFTDescriptor.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The id of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);\n}\n" - }, - "@sablier/v2-core/src/types/DataTypes.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD2x18 } from \"@prb/math/src/UD2x18.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units\n /// of the asset's decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in\n /// the same slot saves gas.\n /// @param deposited The initial amount deposited in the stream, net of fees.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating the deposit amount, the protocol fee amount, and the broker fee amount,\n /// all denoted in units of the asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param protocolFee The protocol fee amount.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 protocolFee;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value STREAMING Active stream where assets are currently being streamed.\n /// @custom:value SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING, // value 0\n STREAMING, // value 1\n SETTLED, // value 2\n CANCELED, // value 3\n DEPLETED // value 4\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithDeltas} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments with deltas used to compose the custom streaming curve. Milestones are calculated by\n /// starting from `block.timestamp` and adding each delta to the previous milestone.\n struct CreateWithDeltas {\n address sender;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n SegmentWithDelta[] segments;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithMilestones}\n /// function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments used to compose the custom streaming curve.\n struct CreateWithMilestones {\n address sender;\n uint40 startTime;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Range {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param milestone The Unix timestamp indicating this segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 milestone;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDeltas}.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param delta The time difference in seconds between this segment and the previous one.\n struct SegmentWithDelta {\n uint128 amount;\n UD2x18 exponent;\n uint40 delta;\n }\n\n /// @notice Lockup Dynamic stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n /// @param segments Segments used to compose the custom streaming curve.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n // slots [4..n]\n Segment[] segments;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithRange} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithRange {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Range range;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end.\n /// @param end The Unix timestamp for the stream's end.\n struct Range {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n /// @notice Lockup Linear stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cliffTime The Unix timestamp indicating the cliff period's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 cliffTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n" - }, - "contracts/interfaces/IDexAggregator.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IDexAggregator {\n struct FormattedOffer {\n uint256[] amounts;\n address[] adapters;\n address[] path;\n uint256 gasEstimate;\n }\n\n struct Trade {\n uint256 amountIn;\n uint256 amountOut;\n address[] path;\n address[] adapters;\n }\n\n function findBestPath(\n uint256 _amountIn,\n address _tokenIn,\n address _tokenOut,\n uint256 _maxSteps\n ) external view returns (FormattedOffer memory);\n\n function swapNoSplitFromAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external payable;\n\n function swapNoSplitToAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n\n function swapNoSplit(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n}\n" - }, - "contracts/interfaces/INonfungiblePositionManager.sol": { - "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Non-fungible token for positions\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\n/// and authorized.\ninterface INonfungiblePositionManager {\n struct MintParams {\n address token0;\n address token1;\n uint24 fee;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n address recipient;\n uint256 deadline;\n }\n\n /// @notice Creates a new position wrapped in a NFT\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\n /// a method does not exist, i.e. the pool is assumed to be initialized.\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\n /// @return tokenId The ID of the token that represents the minted position\n /// @return liquidity The amount of liquidity for this position\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\n function mint(\n MintParams calldata params\n )\n external\n payable\n returns (\n uint256 tokenId,\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n}\n" - }, - "contracts/interfaces/IStratosphere.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IStratosphere {\n function tokenIdOf(address _owner) external view returns (uint256);\n\n function mint() external returns (uint256);\n}\n" - }, - "contracts/interfaces/IVaporDEXFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n" - }, - "contracts/interfaces/IVaporDEXRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXRouter {\n function factory() external view returns (address);\n\n function WETH() external view returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n" - }, - "contracts/MemeFactory.sol": { - "content": "// ███╗░░░███╗███████╗███╗░░░███╗███████╗ ███████╗░█████╗░░█████╗░████████╗░█████╗░██████╗░██╗░░░██╗\n// ████╗░████║██╔════╝████╗░████║██╔════╝ ██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗██╔══██╗╚██╗░██╔╝\n// ██╔████╔██║█████╗░░██╔████╔██║█████╗░░ █████╗░░███████║██║░░╚═╝░░░██║░░░██║░░██║██████╔╝░╚████╔╝░\n// ██║╚██╔╝██║██╔══╝░░██║╚██╔╝██║██╔══╝░░ ██╔══╝░░██╔══██║██║░░██╗░░░██║░░░██║░░██║██╔══██╗░░╚██╔╝░░\n// ██║░╚═╝░██║███████╗██║░╚═╝░██║███████╗ ██║░░░░░██║░░██║╚█████╔╝░░░██║░░░╚█████╔╝██║░░██║░░░██║░░░\n// ╚═╝░░░░░╚═╝╚══════╝╚═╝░░░░░╚═╝╚══════╝ ╚═╝░░░░░╚═╝░░╚═╝░╚════╝░░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝░░░╚═╝░░░\n\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IVaporDEXFactory} from \"./interfaces/IVaporDEXFactory.sol\";\nimport {IVaporDEXRouter} from \"./interfaces/IVaporDEXRouter.sol\";\nimport {Token} from \"./Token.sol\";\nimport {ISablierV2LockupLinear} from \"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\";\nimport {LockupLinear} from \"@sablier/v2-core/src/types/DataTypes.sol\";\nimport {IDexAggregator} from \"./interfaces/IDexAggregator.sol\";\nimport {INonfungiblePositionManager} from \"./interfaces/INonfungiblePositionManager.sol\";\n\nerror MemeFactory__WrongConstructorArguments();\nerror MemeFactory__LiquidityLockedOrDepleted();\nerror MemeFactory__Unauthorized();\nerror MemeFactory__ZeroAddress();\nerror MemeFactory__WrongLaunchArguments();\nerror MemeFactory__InsufficientBalance();\nerror MemeFactory__Invalid();\nerror MemeFactory__TranferFailed(address);\nerror MemeFactory__NotEnoughLiquidity();\nerror MemeFactory__MinimumLockDuration();\n\n/// @title MemeFactory\n/// @author Roy & Jose\n/// @notice This contract is used to launch new tokens and create liquidity for them\n/// @dev Utilizes 'Sablier' for liquidity locking\n\ncontract MemeFactory is Ownable {\n //////////////\n /// EVENTS ///\n //////////////\n\n event TokenLaunched(\n address indexed _tokenAddress,\n address indexed _pairAddress,\n bool _liquidityBurned\n );\n\n event StreamCreated(uint256 indexed _streamId);\n event LiquidityBurned(\n address indexed pair,\n address indexed _burner,\n uint256 _amount\n );\n event LiquidityTokensUnlocked(\n address indexed _pairAddress,\n address indexed _receiver\n );\n event LiquidityTransferred(\n address indexed _pairAddress,\n address indexed _to\n );\n event LaunchFeeUpdated(uint256 _newFee);\n event MinimumLiquidityETHUpdated(uint256 _newFee);\n event MinimumLockDurationUpdated(uint40 _newFee);\n event VaporDEXAdapterUpdated(address _newAdapter);\n event AccumulatedFeesWithdrawn(address _to, uint256 _amount);\n\n ///////////////\n /// STORAGE ///\n ///////////////\n address private immutable factory;\n address private immutable router;\n address private immutable stratosphere;\n IDexAggregator private immutable vaporDexAggregator;\n INonfungiblePositionManager private immutable nonFungiblePositionManager;\n IERC20 private immutable WETH;\n IERC20 private immutable USDC;\n IERC20 private immutable VAPE;\n address private vaporDexAdapter;\n address private teamMultisig;\n uint256 private launchFee;\n uint256 public minLiquidityETH;\n uint40 public minLockDuration;\n\n // Sablier\n ISablierV2LockupLinear private immutable sablier;\n // Mapping to store the streamId for each pair and lp owner\n mapping(address => mapping(address => uint256)) private liquidityLocks;\n\n /**\n * @dev MemeFactory constructor initializes the contract with required parameters.\n * @param _owner Address of the contract owner.\n * @param _routerAddress Address of the VaporDEXRouter contract.\n * @param _stratosphereAddress Address of the Stratosphere contract.\n * @param _vaporDexAggregator Address of the VaporDEX aggregator.\n * @param _vaporDexAdapter Address of the VaporDEX adapter.\n * @param _usdc Address of the USDC token.\n * @param _launchFee Launch fee in USDC.\n * @param _sablier Address of the Sablier contract.\n * @param _nonFungiblePositionManager Uni v3 NFT Position Manager\n * @param _teamMultisig Multisig address\n */\n struct DeployArgs {\n address _owner;\n address _routerAddress;\n address _stratosphereAddress;\n address _vaporDexAggregator;\n address _vaporDexAdapter;\n address _usdc;\n address _vape;\n uint256 _launchFee;\n uint256 _minLiquidityETH;\n uint40 _minLockDuration;\n address _sablier;\n address _nonFungiblePositionManager;\n address _teamMultisig;\n }\n\n /////////////////////////\n ////// CONSTRUCTOR /////\n ////////////////////////\n\n constructor(DeployArgs memory args) Ownable(args._owner) {\n // Check for valid constructor arguments\n if (\n args._owner == address(0) ||\n args._routerAddress == address(0) ||\n args._stratosphereAddress == address(0) ||\n args._vaporDexAggregator == address(0) ||\n args._vaporDexAdapter == address(0) ||\n args._usdc == address(0) ||\n args._launchFee == 0 ||\n args._sablier == address(0) ||\n args._minLiquidityETH == 0 ||\n args._minLockDuration == 0\n ) {\n revert MemeFactory__WrongConstructorArguments();\n }\n\n // Initialize variables\n router = args._routerAddress;\n IVaporDEXRouter _router = IVaporDEXRouter(args._routerAddress);\n factory = _router.factory();\n WETH = IERC20(_router.WETH());\n USDC = IERC20(args._usdc);\n VAPE = IERC20(args._vape);\n minLiquidityETH = args._minLiquidityETH;\n minLockDuration = args._minLockDuration;\n stratosphere = args._stratosphereAddress;\n vaporDexAggregator = IDexAggregator(args._vaporDexAggregator);\n vaporDexAdapter = args._vaporDexAdapter;\n launchFee = args._launchFee;\n sablier = ISablierV2LockupLinear(args._sablier);\n nonFungiblePositionManager = INonfungiblePositionManager(\n args._nonFungiblePositionManager\n );\n teamMultisig = args._teamMultisig;\n }\n\n /**\n * @dev Launches a new token with specified parameters.\n * @param _name Name of the token.\n * @param _symbol Symbol of the token.\n * @param _totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param lockDuration Number of days to lock liquidity for.\n * @param _burnLiquidity Flag indicating whether to burn liquidity or lock it.\n * @return _pair Address of the created token pair.\n * @return _tokenAddress Address of the launched token.\n * @return streamId Stream ID if liquidity is locked, otherwise 0.\n */\n\n function launch(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint256 _tradingStartsAt,\n uint40 lockDuration,\n bool _burnLiquidity\n )\n external\n payable\n returns (address _pair, address _tokenAddress, uint256 streamId)\n {\n uint256 value = msg.value;\n if (value < minLiquidityETH) {\n revert MemeFactory__NotEnoughLiquidity();\n }\n // Step 0: Transfer Fee\n _transferLaunchFee(msg.sender);\n\n // Step 1: Create the token\n Token _token = _createToken(\n _name,\n _symbol,\n _totalSupply,\n _tradingStartsAt,\n address(vaporDexAggregator),\n vaporDexAdapter\n );\n _tokenAddress = address(_token);\n\n // Step 2: Create the pair\n IVaporDEXFactory _factory = IVaporDEXFactory(factory);\n _pair = _factory.createPair(_tokenAddress, address(WETH));\n _token.approve(router, _totalSupply);\n _token.approve(_pair, _totalSupply);\n\n // Step 2: Add Liquidity\n IVaporDEXRouter _router = IVaporDEXRouter(router);\n _router.addLiquidityETH{value: value}(\n _tokenAddress,\n _totalSupply,\n _totalSupply,\n value,\n address(this),\n block.timestamp + 10 minutes\n );\n // Step 3: Get the pair address\n _pair = IVaporDEXFactory(factory).getPair(_tokenAddress, address(WETH));\n if (_pair == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n // Step 4: Set the LP address in the token\n _token.setLiquidityPool(_pair);\n // Step 5: Renounce ownership of the token\n _token.renounceOwnership();\n\n // Step 6: Lock Or Burn Liquidity\n\n IERC20 _lpToken = IERC20(_pair);\n\n if (_burnLiquidity) {\n // Burn Liquidity\n _lpToken.transfer(address(0), _lpToken.balanceOf(address(this)));\n emit LiquidityBurned(\n _pair,\n msg.sender,\n _lpToken.balanceOf(address(this))\n );\n } else {\n if (lockDuration < minLockDuration) {\n revert MemeFactory__MinimumLockDuration();\n }\n _lpToken.approve(\n address(sablier),\n _lpToken.balanceOf(address(this))\n );\n // Lock Liquidity\n // SablierV2\n LockupLinear.CreateWithDurations memory params;\n\n // Declare the function parameters\n params.sender = address(this); // The sender will be able to cancel the stream\n params.recipient = msg.sender; // The recipient of the streamed assets\n params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees\n params.asset = _lpToken; // The streaming asset\n params.cancelable = false; // Whether the stream will be cancelable or not\n params.transferable = true; // Whether the stream will be transferrable or not\n params.durations = LockupLinear.Durations({\n cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period\n total: lockDuration * 1 days\n });\n\n // Create the stream\n streamId = sablier.createWithDurations(params);\n liquidityLocks[msg.sender][_pair] = streamId;\n\n emit StreamCreated(streamId);\n }\n\n // Step 7: Buy VAPE with USDC on VaporDEXAggregator\n\n _buyVapeWithUsdc(launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee\n\n // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2\n\n _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract\n\n emit TokenLaunched(_tokenAddress, _pair, _burnLiquidity);\n }\n\n /**\n * @dev Unlocks liquidity tokens for the specified pair and recipient.\n * @param _pair Address of the token pair.\n * @param _receiver Address of the recipient of unlocked tokens.\n * @notice It is recommended to direct the user to Sablier UI for better error handling.\n */\n function unlockLiquidityTokens(address _pair, address _receiver) external {\n if (_receiver == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n\n if (streamId == 0) {\n revert MemeFactory__Unauthorized();\n }\n\n uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n revert MemeFactory__LiquidityLockedOrDepleted();\n }\n\n sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier\n\n emit LiquidityTokensUnlocked(_pair, _receiver);\n }\n\n /**\n * @dev Transfers the locked liquidity to the specified recipient for the given pair.\n * @param _pair Address of the token pair.\n * @param _to Address of the recipient.\n */\n function transferLock(address _pair, address _to) external {\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n if (\n streamId == 0 ||\n _to == address(0) ||\n sablier.isTransferable(streamId) == false\n ) {\n revert MemeFactory__Unauthorized();\n }\n\n liquidityLocks[_to][_pair] = streamId;\n liquidityLocks[msg.sender][_pair] = 0;\n\n sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier\n\n emit LiquidityTransferred(_pair, _to);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _liquidity New liquidity.\n */\n\n function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner {\n if (_liquidity == 0) {\n revert MemeFactory__Invalid();\n }\n minLiquidityETH = _liquidity;\n emit MinimumLiquidityETHUpdated(_liquidity);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _lockDuration New lock duration in days.\n */\n\n function setMinLockDuration(uint40 _lockDuration) external onlyOwner {\n if (_lockDuration == 0) {\n revert MemeFactory__Invalid();\n }\n minLockDuration = _lockDuration;\n emit MinimumLockDurationUpdated(_lockDuration);\n }\n\n /**\n * @dev Sets the launch fee for creating new tokens.\n * @param _launchFee New launch fee in USDC.\n */\n\n function setLaunchFee(uint256 _launchFee) external onlyOwner {\n if (_launchFee == 0) {\n revert MemeFactory__Invalid();\n }\n launchFee = _launchFee;\n emit LaunchFeeUpdated(_launchFee);\n }\n\n /**\n * @dev Sets the VaporDEX adapter address.\n * @param _vaporDexAdapter New VaporDEX adapter address.\n */\n\n function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner {\n if (\n _vaporDexAdapter == vaporDexAdapter ||\n _vaporDexAdapter == address(0)\n ) {\n revert MemeFactory__Invalid();\n }\n vaporDexAdapter = _vaporDexAdapter;\n emit VaporDEXAdapterUpdated(_vaporDexAdapter);\n }\n\n /**\n * @dev Withdraws any remaining USDC fees to the specified address.\n * @param _to Address to which the remaining fees are withdrawn.\n */\n\n function withdrawFee(address _to) external onlyOwner {\n if (_to == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n IERC20 _usdc = IERC20(USDC);\n _usdc.transfer(_to, _usdc.balanceOf(address(this)));\n emit AccumulatedFeesWithdrawn(_to, _usdc.balanceOf(address(this)));\n }\n\n /**\n * @dev Creates a new Token contract with specified parameters.\n * @param name Name of the token.\n * @param symbol Symbol of the token.\n * @param totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param dexAggregator Address of the decentralized exchange aggregator.\n * @param dexAdapter Address of the decentralized exchange adapter.\n * @return _token Instance of the created Token contract.\n */\n function _createToken(\n string memory name,\n string memory symbol,\n uint256 totalSupply,\n uint256 _tradingStartsAt,\n address dexAggregator,\n address dexAdapter\n ) internal returns (Token _token) {\n if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) {\n revert MemeFactory__WrongLaunchArguments();\n }\n _token = new Token(\n name,\n symbol,\n totalSupply,\n stratosphere,\n address(this),\n _tradingStartsAt,\n dexAggregator,\n dexAdapter\n );\n }\n\n /**\n * @dev Transfers the launch fee in USDC from the sender.\n * @param _from Address from which the launch fee is transferred.\n */\n\n function _transferLaunchFee(address _from) internal {\n IERC20 _usdc = IERC20(USDC);\n if (_usdc.balanceOf(_from) < launchFee) {\n revert MemeFactory__InsufficientBalance();\n }\n bool isSuccess = _usdc.transferFrom(_from, address(this), launchFee);\n if (!isSuccess) {\n revert MemeFactory__TranferFailed(_from);\n }\n }\n\n /**\n * @dev Buys VAPE with USDC on VaporDEXAggregator\n * @param amountIn Amount of USDC to be used for buying VAPE.\n */\n\n function _buyVapeWithUsdc(uint256 amountIn) internal {\n USDC.approve(address(vaporDexAggregator), amountIn);\n\n IDexAggregator.FormattedOffer memory offer = vaporDexAggregator\n .findBestPath(\n amountIn,\n address(USDC),\n address(VAPE),\n 1 // can be changed to 3\n );\n IDexAggregator.Trade memory trade;\n trade.amountIn = amountIn;\n trade.amountOut = offer.amounts[offer.amounts.length - 1];\n trade.path = offer.path;\n trade.adapters = offer.adapters;\n vaporDexAggregator.swapNoSplit(trade, address(this), 0);\n }\n\n /**\n * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2.\n * @notice Uses the balance of VAPE and USDC in the contract.\n */\n\n function _addLiquidityVapeUsdc() internal {\n uint256 amountInUSDC = USDC.balanceOf(address(this));\n uint256 amountInVAPE = VAPE.balanceOf(address(this));\n USDC.approve(address(nonFungiblePositionManager), amountInUSDC);\n VAPE.approve(address(nonFungiblePositionManager), amountInVAPE);\n INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager\n .MintParams({\n token0: address(VAPE),\n token1: address(USDC),\n fee: 3000,\n tickLower: -887220, // full range\n tickUpper: 887220, // full range\n amount0Desired: amountInVAPE,\n amount1Desired: amountInUSDC,\n amount0Min: amountInVAPE - _percentage(amountInVAPE, 200), // 2% slippage\n amount1Min: amountInUSDC - _percentage(amountInUSDC, 200), // 2% slippage\n recipient: teamMultisig,\n deadline: block.timestamp + 2 minutes\n });\n nonFungiblePositionManager.mint(mintParams);\n\n // Q: What checks should be done with the return values?\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n\n // Getters\n\n /**\n * @dev Returns the launch fee.\n * @return uint256 The launch fee.\n */\n function getLaunchFee() external view returns (uint256) {\n return launchFee;\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDexAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the VaporDEX router.\n * @return address The address of the VaporDEX router.\n */\n function getVaporDEXRouter() external view returns (address) {\n return router;\n }\n\n /**\n * @dev Returns the address of the VaporDEX factory.\n * @return address The address of the VaporDEX factory.\n */\n function getVaporDEXFactory() external view returns (address) {\n return factory;\n }\n\n /**\n * @dev Returns the address of the Stratosphere contract.\n * @return address The address of the Stratosphere contract.\n */\n function getStratosphere() external view returns (address) {\n return stratosphere;\n }\n\n /**\n * @dev Returns the address of the VaporDEX aggregator.\n * @return address The address of the VaporDEX aggregator.\n */\n function getVaporDexAggregator() external view returns (address) {\n return address(vaporDexAggregator);\n }\n\n /**\n * @dev Returns the address of the USDC token.\n * @return address The address of the USDC token.\n */\n function getUSDC() external view returns (address) {\n return address(USDC);\n }\n\n /**\n * @dev Returns the address of the VAPE token.\n * @return address The address of the VAPE token.\n */\n function getVAPE() external view returns (address) {\n return address(VAPE);\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDEXAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the team multisig wallet.\n * @return address The address of the team multisig wallet.\n */\n function getTeamMultisig() external view returns (address) {\n return teamMultisig;\n }\n\n /**\n * @dev Returns the address of the Sablier contract.\n * @return address The address of the Sablier contract.\n */\n function getSablier() external view returns (address) {\n return address(sablier);\n }\n\n /**\n * @dev Returns the address of the NonFungiblePositionManager contract.\n * @return address The address of the NonFungiblePositionManager contract.\n */\n function getNonFungiblePositionManager() external view returns (address) {\n return address(nonFungiblePositionManager);\n }\n\n /**\n * @dev Returns the liquidity lock for the specified pair and owner.\n * @param _pair Address of the token pair.\n * @param _owner Address of the owner.\n * @return uint256 Stream ID for the liquidity lock.\n */\n\n function getLiquidityLock(\n address _pair,\n address _owner\n ) external view returns (uint256) {\n return liquidityLocks[_owner][_pair];\n }\n}\n" - }, - "contracts/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ERC20Permit} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IStratosphere} from \"./interfaces/IStratosphere.sol\";\n\nerror Token__MissingLiquidityPool();\nerror Token__ExceedsMaximumHolding();\nerror Token__TradingNotStarted();\nerror Token__NonStratosphereNFTHolder();\nerror Token__BotDetected();\n\ncontract Token is ERC20, ERC20Permit, Ownable {\n address public liquidityPool;\n address public immutable dexAggregator;\n address public immutable dexAdapter;\n uint256 public immutable maxHoldingAmount;\n uint256 public immutable tradingStartsAt;\n IStratosphere public immutable stratosphere;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _supply,\n address _stratosphereAddress,\n address _owner,\n uint256 _tradingStartsAt,\n address _dexAggregator,\n address _dexAdapter\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\n stratosphere = IStratosphere(_stratosphereAddress);\n _mint(msg.sender, _supply);\n maxHoldingAmount = _percentage(_supply, 100); // 1% of total supply\n tradingStartsAt = _tradingStartsAt;\n dexAggregator = _dexAggregator;\n dexAdapter = _dexAdapter;\n }\n\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\n if (_liquidityPool == address(0)) {\n revert Token__MissingLiquidityPool();\n }\n liquidityPool = _liquidityPool;\n }\n\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\n function _update(\n address from,\n address to,\n uint256 value\n ) internal virtual override {\n super._update(from, to, value);\n uint256 _tradingStartsAt = tradingStartsAt;\n\n if (liquidityPool == address(0)) {\n require(\n from == owner() || to == owner(),\n \"Patience - Trading Not Started Yet!\"\n );\n return;\n }\n\n if (block.timestamp < _tradingStartsAt) {\n revert Token__TradingNotStarted();\n }\n\n uint256 _secondsSinceTradingStarted = block.timestamp -\n _tradingStartsAt;\n\n if (_secondsSinceTradingStarted > 24 hours) {\n return;\n }\n\n if (_secondsSinceTradingStarted < 1 hours) {\n _enforceAntiWhale(to, value);\n if (!(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to))) {\n revert Token__NonStratosphereNFTHolder();\n }\n } else if (_secondsSinceTradingStarted < 24 hours) {\n _enforceAntiWhale(to, value);\n }\n }\n\n function _enforceAntiWhale(address to, uint256 value) internal view {\n if (to != liquidityPool) {\n uint256 newBalance = balanceOf(to) + value;\n if (newBalance > maxHoldingAmount) {\n revert Token__ExceedsMaximumHolding();\n }\n }\n }\n\n function _isStratosphereMemberOrAdmin(address _address) internal view returns (bool pass) {\n if (_address == dexAggregator || _address == dexAdapter || stratosphere.tokenIdOf(_address) != 0 ||\n _address == liquidityPool) {\n pass = true;\n }\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n}\n" - } - }, - "settings": { - "evmVersion": "paris", - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/avalancheFuji/solcInputs/e2bbf2e09e54377e94c1aabdd9a0338c.json b/deployments/avalancheFuji/solcInputs/e2bbf2e09e54377e94c1aabdd9a0338c.json deleted file mode 100644 index 6419a83..0000000 --- a/deployments/avalancheFuji/solcInputs/e2bbf2e09e54377e94c1aabdd9a0338c.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" - }, - "@openzeppelin/contracts/interfaces/IERC5267.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n bytes32 private constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Permit deadline has expired.\n */\n error ERC2612ExpiredSignature(uint256 deadline);\n\n /**\n * @dev Mismatched signature.\n */\n error ERC2612InvalidSigner(address signer, address owner);\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @inheritdoc IERC20Permit\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > deadline) {\n revert ERC2612ExpiredSignature(deadline);\n }\n\n bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n if (signer != owner) {\n revert ERC2612InvalidSigner(signer, owner);\n }\n\n _approve(owner, spender, value);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n return super.nonces(owner);\n }\n\n /**\n * @inheritdoc IERC20Permit\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparatorV4();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n * {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n * a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the address zero.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Nonces.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/ShortStrings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" - }, - "@prb/math/src/Common.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n" - }, - "@prb/math/src/sd1x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd1x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n" - }, - "@prb/math/src/sd1x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n" - }, - "@prb/math/src/sd1x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n" - }, - "@prb/math/src/sd59x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n" - }, - "@prb/math/src/sd59x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n" - }, - "@prb/math/src/sd59x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n" - }, - "@prb/math/src/sd59x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/sd59x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n" - }, - "@prb/math/src/sd59x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n" - }, - "@prb/math/src/UD2x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗╚════██╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║ █████╔╝ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══╝ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud2x18/Casting.sol\";\nimport \"./ud2x18/Constants.sol\";\nimport \"./ud2x18/Errors.sol\";\nimport \"./ud2x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud2x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud2x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n" - }, - "@prb/math/src/ud2x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n" - }, - "@prb/math/src/ud2x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n" - }, - "@prb/math/src/UD60x18.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n" - }, - "@prb/math/src/ud60x18/Casting.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n" - }, - "@prb/math/src/ud60x18/Constants.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n" - }, - "@prb/math/src/ud60x18/Conversions.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n" - }, - "@prb/math/src/ud60x18/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n" - }, - "@prb/math/src/ud60x18/Helpers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n" - }, - "@prb/math/src/ud60x18/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n///\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n" - }, - "@prb/math/src/ud60x18/ValueType.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n" - }, - "@sablier/v2-core/src/interfaces/IAdminable.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\n/// @title IAdminable\n/// @notice Contract module that provides a basic access control mechanism, with an admin that can be\n/// granted exclusive access to specific functions. The inheriting contract must set the initial admin\n/// in the constructor.\ninterface IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin is transferred.\n /// @param oldAdmin The address of the old admin.\n /// @param newAdmin The address of the new admin.\n event TransferAdmin(address indexed oldAdmin, address indexed newAdmin);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the admin account or contract.\n function admin() external view returns (address);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Transfers the contract admin to a new address.\n ///\n /// @dev Notes:\n /// - Does not revert if the admin is the same.\n /// - This function can potentially leave the contract without an admin, thereby removing any\n /// functionality that is only available to the admin.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newAdmin The address of the new admin.\n function transferAdmin(address newAdmin) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Base.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\nimport { ISablierV2Comptroller } from \"./ISablierV2Comptroller.sol\";\n\n/// @title ISablierV2Base\n/// @notice Base logic for all Sablier V2 streaming contracts.\ninterface ISablierV2Base is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin claims all protocol revenues accrued for a particular ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the protocol revenues have been claimed for.\n /// @param protocolRevenues The amount of protocol revenues claimed, denoted in units of the asset's decimals.\n event ClaimProtocolRevenues(address indexed admin, IERC20 indexed asset, uint128 protocolRevenues);\n\n /// @notice Emitted when the admin sets a new comptroller contract.\n /// @param admin The address of the contract admin.\n /// @param oldComptroller The address of the old comptroller contract.\n /// @param newComptroller The address of the new comptroller contract.\n event SetComptroller(\n address indexed admin, ISablierV2Comptroller oldComptroller, ISablierV2Comptroller newComptroller\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the maximum fee that can be charged by the protocol or a broker, denoted as a fixed-point\n /// number where 1e18 is 100%.\n /// @dev This value is hard coded as a constant.\n function MAX_FEE() external view returns (UD60x18);\n\n /// @notice Retrieves the address of the comptroller contract, responsible for the Sablier V2 protocol\n /// configuration.\n function comptroller() external view returns (ISablierV2Comptroller);\n\n /// @notice Retrieves the protocol revenues accrued for the provided ERC-20 asset, in units of the asset's\n /// decimals.\n /// @param asset The contract address of the ERC-20 asset to query.\n function protocolRevenues(IERC20 asset) external view returns (uint128 revenues);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Claims all accumulated protocol revenues for the provided ERC-20 asset.\n ///\n /// @dev Emits a {ClaimProtocolRevenues} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset for which to claim protocol revenues.\n function claimProtocolRevenues(IERC20 asset) external;\n\n /// @notice Assigns a new comptroller contract responsible for the protocol configuration.\n ///\n /// @dev Emits a {SetComptroller} event.\n ///\n /// Notes:\n /// - Does not revert if the comptroller is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newComptroller The address of the new comptroller contract.\n function setComptroller(ISablierV2Comptroller newComptroller) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Comptroller.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\nimport { IAdminable } from \"./IAdminable.sol\";\n\n/// @title ISablierV2Controller\n/// @notice This contract is in charge of the Sablier V2 protocol configuration, handling such values as the\n/// protocol fees.\ninterface ISablierV2Comptroller is IAdminable {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when the admin sets a new flash fee.\n /// @param admin The address of the contract admin.\n /// @param oldFlashFee The old flash fee, denoted as a fixed-point number.\n /// @param newFlashFee The new flash fee, denoted as a fixed-point number.\n event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);\n\n /// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.\n /// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.\n event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);\n\n /// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.\n /// @param admin The address of the contract admin.\n /// @param asset The contract address of the ERC-20 asset to toggle.\n /// @param newFlag Whether the ERC-20 asset can be flash loaned.\n event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.\n ///\n /// @dev Notes:\n /// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},\n /// which calculates the fee amount for a specified flash loan amount.\n /// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.\n function flashFee() external view returns (UD60x18 fee);\n\n /// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.\n /// @param token The contract address of the ERC-20 asset to check.\n function isFlashAsset(IERC20 token) external view returns (bool result);\n\n /// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.\n /// @param asset The contract address of the ERC-20 asset to query.\n /// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.\n function protocolFees(IERC20 asset) external view returns (UD60x18 fee);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.\n ///\n /// @dev Emits a {SetFlashFee} event.\n ///\n /// Notes:\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.\n function setFlashFee(UD60x18 newFlashFee) external;\n\n /// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.\n ///\n /// @dev Emits a {SetProtocolFee} event.\n ///\n /// Notes:\n /// - The fee is not denoted in units of the asset's decimals; it is a fixed-point number. Refer to the\n /// PRBMath documentation for more detail on the logic of UD60x18.\n /// - Does not revert if the fee is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param asset The contract address of the ERC-20 asset to update the fee for.\n /// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.\n function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;\n\n /// @notice Toggles the flash loanability of an ERC-20 asset.\n ///\n /// @dev Emits a {ToggleFlashAsset} event.\n ///\n /// Requirements:\n /// - `msg.sender` must be the admin.\n ///\n /// @param asset The address of the ERC-20 asset to toggle.\n function toggleFlashAsset(IERC20 asset) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2Lockup.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\nimport { Lockup } from \"../types/DataTypes.sol\";\nimport { ISablierV2Base } from \"./ISablierV2Base.sol\";\nimport { ISablierV2NFTDescriptor } from \"./ISablierV2NFTDescriptor.sol\";\n\n/// @title ISablierV2Lockup\n/// @notice Common logic between all Sablier V2 Lockup streaming contracts.\ninterface ISablierV2Lockup is\n ISablierV2Base, // 1 inherited component\n IERC721Metadata // 2 inherited components\n{\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is canceled.\n /// @param streamId The id of the stream.\n /// @param sender The address of the stream's sender.\n /// @param recipient The address of the stream's recipient.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param senderAmount The amount of assets refunded to the stream's sender, denoted in units of the asset's\n /// decimals.\n /// @param recipientAmount The amount of assets left for the stream's recipient to withdraw, denoted in units of the\n /// asset's decimals.\n event CancelLockupStream(\n uint256 streamId,\n address indexed sender,\n address indexed recipient,\n IERC20 indexed asset,\n uint128 senderAmount,\n uint128 recipientAmount\n );\n\n /// @notice Emitted when a sender gives up the right to cancel a stream.\n /// @param streamId The id of the stream.\n event RenounceLockupStream(uint256 indexed streamId);\n\n /// @notice Emitted when the admin sets a new NFT descriptor contract.\n /// @param admin The address of the current contract admin.\n /// @param oldNFTDescriptor The address of the old NFT descriptor contract.\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n event SetNFTDescriptor(\n address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor\n );\n\n /// @notice Emitted when assets are withdrawn from a stream.\n /// @param streamId The id of the stream.\n /// @param to The address that has received the withdrawn assets.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param amount The amount of assets withdrawn, denoted in units of the asset's decimals.\n event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, IERC20 indexed asset, uint128 amount);\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the address of the ERC-20 asset used for streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getAsset(uint256 streamId) external view returns (IERC20 asset);\n\n /// @notice Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);\n\n /// @notice Retrieves the stream's end time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getEndTime(uint256 streamId) external view returns (uint40 endTime);\n\n /// @notice Retrieves the stream's recipient.\n /// @dev Reverts if the NFT has been burned.\n /// @param streamId The stream id for the query.\n function getRecipient(uint256 streamId) external view returns (address recipient);\n\n /// @notice Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's\n /// decimals. This amount is always zero unless the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);\n\n /// @notice Retrieves the stream's sender.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getSender(uint256 streamId) external view returns (address sender);\n\n /// @notice Retrieves the stream's start time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStartTime(uint256 streamId) external view returns (uint40 startTime);\n\n /// @notice Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);\n\n /// @notice Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this\n /// flag is always `false`.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCancelable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isCold(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is depleted.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isDepleted(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream exists.\n /// @dev Does not revert if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isStream(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream NFT can be transferred.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isTransferable(uint256 streamId) external view returns (bool result);\n\n /// @notice Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function isWarm(uint256 streamId) external view returns (bool result);\n\n /// @notice Counter for stream ids, used in the create functions.\n function nextStreamId() external view returns (uint256);\n\n /// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units\n /// of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);\n\n /// @notice Retrieves the stream's status.\n /// @param streamId The stream id for the query.\n function statusOf(uint256 streamId) external view returns (Lockup.Status status);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /// @notice Retrieves a flag indicating whether the stream was canceled.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function wasCanceled(uint256 streamId) external view returns (bool result);\n\n /// @notice Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's\n /// decimals.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Burns the NFT associated with the stream.\n ///\n /// @dev Emits a {Transfer} event.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a depleted stream.\n /// - The NFT must exist.\n /// - `msg.sender` must be either the NFT owner or an approved third party.\n ///\n /// @param streamId The id of the stream NFT to burn.\n function burn(uint256 streamId) external;\n\n /// @notice Cancels the stream and refunds any remaining assets to the sender.\n ///\n /// @dev Emits a {Transfer}, {CancelLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the\n /// stream is marked as depleted.\n /// - This function attempts to invoke a hook on the recipient, if the resolved address is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - The stream must be warm and cancelable.\n /// - `msg.sender` must be the stream's sender.\n ///\n /// @param streamId The id of the stream to cancel.\n function cancel(uint256 streamId) external;\n\n /// @notice Cancels multiple streams and refunds any remaining assets to the sender.\n ///\n /// @dev Emits multiple {Transfer}, {CancelLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - Refer to the notes in {cancel}.\n ///\n /// Requirements:\n /// - All requirements from {cancel} must be met for each stream.\n ///\n /// @param streamIds The ids of the streams to cancel.\n function cancelMultiple(uint256[] calldata streamIds) external;\n\n /// @notice Removes the right of the stream's sender to cancel the stream.\n ///\n /// @dev Emits a {RenounceLockupStream} and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This is an irreversible operation.\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must reference a warm stream.\n /// - `msg.sender` must be the stream's sender.\n /// - The stream must be cancelable.\n ///\n /// @param streamId The id of the stream to renounce.\n function renounce(uint256 streamId) external;\n\n /// @notice Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.\n ///\n /// @dev Emits a {SetNFTDescriptor} and {BatchMetadataUpdate} event.\n ///\n /// Notes:\n /// - Does not revert if the NFT descriptor is the same.\n ///\n /// Requirements:\n /// - `msg.sender` must be the contract admin.\n ///\n /// @param newNFTDescriptor The address of the new NFT descriptor contract.\n function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;\n\n /// @notice Withdraws the provided amount of assets from the stream to the `to` address.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract\n /// and `msg.sender` is either the sender or an approved operator.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `streamId` must not reference a null or depleted stream.\n /// - `msg.sender` must be the stream's sender, the stream's recipient or an approved third party.\n /// - `to` must be the recipient if `msg.sender` is the stream's sender.\n /// - `to` must not be the zero address.\n /// - `amount` must be greater than zero and must not exceed the withdrawable amount.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amount The amount to withdraw, denoted in units of the asset's decimals.\n function withdraw(uint256 streamId, address to, uint128 amount) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the provided address `to`.\n ///\n /// @dev Emits a {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} event.\n ///\n /// Notes:\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - Refer to the requirements in {withdraw}.\n ///\n /// @param streamId The id of the stream to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n function withdrawMax(uint256 streamId, address to) external;\n\n /// @notice Withdraws the maximum withdrawable amount from the stream to the current recipient, and transfers the\n /// NFT to `newRecipient`.\n ///\n /// @dev Emits a {WithdrawFromLockupStream} and a {Transfer} event.\n ///\n /// Notes:\n /// - If the withdrawable amount is zero, the withdrawal is skipped.\n /// - Refer to the notes in {withdraw}.\n ///\n /// Requirements:\n /// - `msg.sender` must be the stream's recipient.\n /// - Refer to the requirements in {withdraw}.\n /// - Refer to the requirements in {IERC721.transferFrom}.\n ///\n /// @param streamId The id of the stream NFT to transfer.\n /// @param newRecipient The address of the new owner of the stream NFT.\n function withdrawMaxAndTransfer(uint256 streamId, address newRecipient) external;\n\n /// @notice Withdraws assets from streams to the provided address `to`.\n ///\n /// @dev Emits multiple {Transfer}, {WithdrawFromLockupStream}, and {MetadataUpdate} events.\n ///\n /// Notes:\n /// - This function attempts to call a hook on the recipient of each stream, unless `msg.sender` is the recipient.\n ///\n /// Requirements:\n /// - All requirements from {withdraw} must be met for each stream.\n /// - There must be an equal number of `streamIds` and `amounts`.\n ///\n /// @param streamIds The ids of the streams to withdraw from.\n /// @param to The address receiving the withdrawn assets.\n /// @param amounts The amounts to withdraw, denoted in units of the asset's decimals.\n function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport { Lockup, LockupLinear } from \"../types/DataTypes.sol\";\nimport { ISablierV2Lockup } from \"./ISablierV2Lockup.sol\";\n\n/// @title ISablierV2LockupLinear\n/// @notice Creates and manages Lockup streams with linear streaming functions.\ninterface ISablierV2LockupLinear is ISablierV2Lockup {\n /*//////////////////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Emitted when a stream is created.\n /// @param streamId The id of the newly created stream.\n /// @param funder The address which funded the stream.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param recipient The address receiving the assets.\n /// @param amounts Struct containing (i) the deposit amount, (ii) the protocol fee amount, and (iii) the\n /// broker fee amount, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Boolean indicating whether the stream will be cancelable or not.\n /// @param transferable Boolean indicating whether the stream NFT is transferable or not.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker The address of the broker who has helped create the stream, e.g. a front-end website.\n event CreateLockupLinearStream(\n uint256 streamId,\n address funder,\n address indexed sender,\n address indexed recipient,\n Lockup.CreateAmounts amounts,\n IERC20 indexed asset,\n bool cancelable,\n bool transferable,\n LockupLinear.Range range,\n address broker\n );\n\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Retrieves the stream's cliff time, which is a Unix timestamp.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);\n\n /// @notice Retrieves the stream's range, which is a struct containing (i) the stream's start time, (ii) cliff\n /// time, and (iii) end time, all as Unix timestamps.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);\n\n /// @notice Retrieves the stream entity.\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);\n\n /// @notice Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.\n ///\n /// When the stream is warm, the streaming function is:\n ///\n /// $$\n /// f(x) = x * d + c\n /// $$\n ///\n /// Where:\n ///\n /// - $x$ is the elapsed time divided by the stream's total duration.\n /// - $d$ is the deposited amount.\n /// - $c$ is the cliff amount.\n ///\n /// Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited\n /// amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent\n /// to the total amount withdrawn.\n ///\n /// @dev Reverts if `streamId` references a null stream.\n /// @param streamId The stream id for the query.\n function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);\n\n /*//////////////////////////////////////////////////////////////////////////\n NON-CONSTANT FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n /// @notice Creates a stream by setting the start time to `block.timestamp`, and the end time to\n /// the sum of `block.timestamp` and `params.durations.total`. The stream is funded by `msg.sender` and is wrapped\n /// in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Requirements:\n /// - All requirements in {createWithRange} must be met for the calculated parameters.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithDurations(LockupLinear.CreateWithDurations calldata params)\n external\n returns (uint256 streamId);\n\n /// @notice Creates a stream with the provided start time and end time as the range. The stream is\n /// funded by `msg.sender` and is wrapped in an ERC-721 NFT.\n ///\n /// @dev Emits a {Transfer} and {CreateLockupLinearStream} event.\n ///\n /// Notes:\n /// - As long as the times are ordered, it is not an error for the start or the cliff time to be in the past.\n ///\n /// Requirements:\n /// - Must not be delegate called.\n /// - `params.totalAmount` must be greater than zero.\n /// - If set, `params.broker.fee` must not be greater than `MAX_FEE`.\n /// - `params.range.start` must be less than or equal to `params.range.cliff`.\n /// - `params.range.cliff` must be less than `params.range.end`.\n /// - `params.range.end` must be in the future.\n /// - `params.recipient` must not be the zero address.\n /// - `msg.sender` must have allowed this contract to spend at least `params.totalAmount` assets.\n ///\n /// @param params Struct encapsulating the function parameters, which are documented in {DataTypes}.\n /// @return streamId The id of the newly created stream.\n function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);\n}\n" - }, - "@sablier/v2-core/src/interfaces/ISablierV2NFTDescriptor.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC721Metadata } from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\n\n/// @title ISablierV2NFTDescriptor\n/// @notice This contract generates the URI describing the Sablier V2 stream NFTs.\n/// @dev Inspired by Uniswap V3 Positions NFTs.\ninterface ISablierV2NFTDescriptor {\n /// @notice Produces the URI describing a particular stream NFT.\n /// @dev This is a data URI with the JSON contents directly inlined.\n /// @param sablier The address of the Sablier contract the stream was created in.\n /// @param streamId The id of the stream for which to produce a description.\n /// @return uri The URI of the ERC721-compliant metadata.\n function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);\n}\n" - }, - "@sablier/v2-core/src/types/DataTypes.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.19;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { UD2x18 } from \"@prb/math/src/UD2x18.sol\";\nimport { UD60x18 } from \"@prb/math/src/UD60x18.sol\";\n\n// DataTypes.sol\n//\n// This file defines all structs used in V2 Core, most of which are organized under three namespaces:\n//\n// - Lockup\n// - LockupDynamic\n// - LockupLinear\n//\n// You will notice that some structs contain \"slot\" annotations - they are used to indicate the\n// storage layout of the struct. It is more gas efficient to group small data types together so\n// that they fit in a single 32-byte slot.\n\n/// @notice Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.\n/// @param account The address receiving the broker's fee.\n/// @param fee The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.\nstruct Broker {\n address account;\n UD60x18 fee;\n}\n\n/// @notice Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.\nlibrary Lockup {\n /// @notice Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units\n /// of the asset's decimals.\n /// @dev Because the deposited and the withdrawn amount are often read together, declaring them in\n /// the same slot saves gas.\n /// @param deposited The initial amount deposited in the stream, net of fees.\n /// @param withdrawn The cumulative amount withdrawn from the stream.\n /// @param refunded The amount refunded to the sender. Unless the stream was canceled, this is always zero.\n struct Amounts {\n // slot 0\n uint128 deposited;\n uint128 withdrawn;\n // slot 1\n uint128 refunded;\n }\n\n /// @notice Struct encapsulating the deposit amount, the protocol fee amount, and the broker fee amount,\n /// all denoted in units of the asset's decimals.\n /// @param deposit The amount to deposit in the stream.\n /// @param protocolFee The protocol fee amount.\n /// @param brokerFee The broker fee amount.\n struct CreateAmounts {\n uint128 deposit;\n uint128 protocolFee;\n uint128 brokerFee;\n }\n\n /// @notice Enum representing the different statuses of a stream.\n /// @custom:value PENDING Stream created but not started; assets are in a pending state.\n /// @custom:value STREAMING Active stream where assets are currently being streamed.\n /// @custom:value SETTLED All assets have been streamed; recipient is due to withdraw them.\n /// @custom:value CANCELED Canceled stream; remaining assets await recipient's withdrawal.\n /// @custom:value DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.\n enum Status {\n PENDING, // value 0\n STREAMING, // value 1\n SETTLED, // value 2\n CANCELED, // value 3\n DEPLETED // value 4\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupDynamic}.\nlibrary LockupDynamic {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithDeltas} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments with deltas used to compose the custom streaming curve. Milestones are calculated by\n /// starting from `block.timestamp` and adding each delta to the previous milestone.\n struct CreateWithDeltas {\n address sender;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n SegmentWithDelta[] segments;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupDynamic.createWithMilestones}\n /// function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n /// @param segments Segments used to compose the custom streaming curve.\n struct CreateWithMilestones {\n address sender;\n uint40 startTime;\n bool cancelable;\n bool transferable;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n Broker broker;\n Segment[] segments;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp indicating the stream's start.\n /// @param end The Unix timestamp indicating the stream's end.\n struct Range {\n uint40 start;\n uint40 end;\n }\n\n /// @notice Segment struct used in the Lockup Dynamic stream.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param milestone The Unix timestamp indicating this segment's end.\n struct Segment {\n // slot 0\n uint128 amount;\n UD2x18 exponent;\n uint40 milestone;\n }\n\n /// @notice Segment struct used at runtime in {SablierV2LockupDynamic.createWithDeltas}.\n /// @param amount The amount of assets to be streamed in this segment, denoted in units of the asset's decimals.\n /// @param exponent The exponent of this segment, denoted as a fixed-point number.\n /// @param delta The time difference in seconds between this segment and the previous one.\n struct SegmentWithDelta {\n uint128 amount;\n UD2x18 exponent;\n uint40 delta;\n }\n\n /// @notice Lockup Dynamic stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n /// @param segments Segments used to compose the custom streaming curve.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 endTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n // slots [4..n]\n Segment[] segments;\n }\n}\n\n/// @notice Namespace for the structs used in {SablierV2LockupLinear}.\nlibrary LockupLinear {\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithDurations} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param durations Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithDurations {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Durations durations;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the parameters for the {SablierV2LockupLinear.createWithRange} function.\n /// @param sender The address streaming the assets, with the ability to cancel the stream. It doesn't have to be the\n /// same as `msg.sender`.\n /// @param recipient The address receiving the assets.\n /// @param totalAmount The total amount of ERC-20 assets to be paid, including the stream deposit and any potential\n /// fees, all denoted in units of the asset's decimals.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param cancelable Indicates if the stream is cancelable.\n /// @param transferable Indicates if the stream NFT is transferable.\n /// @param range Struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix\n /// timestamps.\n /// @param broker Struct containing (i) the address of the broker assisting in creating the stream, and (ii) the\n /// percentage fee paid to the broker from `totalAmount`, denoted as a fixed-point number. Both can be set to zero.\n struct CreateWithRange {\n address sender;\n address recipient;\n uint128 totalAmount;\n IERC20 asset;\n bool cancelable;\n bool transferable;\n Range range;\n Broker broker;\n }\n\n /// @notice Struct encapsulating the cliff duration and the total duration.\n /// @param cliff The cliff duration in seconds.\n /// @param total The total duration in seconds.\n struct Durations {\n uint40 cliff;\n uint40 total;\n }\n\n /// @notice Struct encapsulating the time range.\n /// @param start The Unix timestamp for the stream's start.\n /// @param cliff The Unix timestamp for the cliff period's end.\n /// @param end The Unix timestamp for the stream's end.\n struct Range {\n uint40 start;\n uint40 cliff;\n uint40 end;\n }\n\n /// @notice Lockup Linear stream.\n /// @dev The fields are arranged like this to save gas via tight variable packing.\n /// @param sender The address streaming the assets, with the ability to cancel the stream.\n /// @param startTime The Unix timestamp indicating the stream's start.\n /// @param cliffTime The Unix timestamp indicating the cliff period's end.\n /// @param isCancelable Boolean indicating if the stream is cancelable.\n /// @param wasCanceled Boolean indicating if the stream was canceled.\n /// @param asset The contract address of the ERC-20 asset used for streaming.\n /// @param endTime The Unix timestamp indicating the stream's end.\n /// @param isDepleted Boolean indicating if the stream is depleted.\n /// @param isStream Boolean indicating if the struct entity exists.\n /// @param isTransferable Boolean indicating if the stream NFT is transferable.\n /// @param amounts Struct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the\n /// asset's decimals.\n struct Stream {\n // slot 0\n address sender;\n uint40 startTime;\n uint40 cliffTime;\n bool isCancelable;\n bool wasCanceled;\n // slot 1\n IERC20 asset;\n uint40 endTime;\n bool isDepleted;\n bool isStream;\n bool isTransferable;\n // slot 2 and 3\n Lockup.Amounts amounts;\n }\n}\n" - }, - "contracts/interfaces/IDexAggregator.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IDexAggregator {\n struct FormattedOffer {\n uint256[] amounts;\n address[] adapters;\n address[] path;\n uint256 gasEstimate;\n }\n\n struct Trade {\n uint256 amountIn;\n uint256 amountOut;\n address[] path;\n address[] adapters;\n }\n\n function findBestPath(\n uint256 _amountIn,\n address _tokenIn,\n address _tokenOut,\n uint256 _maxSteps\n ) external view returns (FormattedOffer memory);\n\n function swapNoSplitFromAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external payable;\n\n function swapNoSplitToAVAX(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n\n function swapNoSplit(\n Trade calldata _trade,\n address _to,\n uint256 _fee\n ) external;\n}\n" - }, - "contracts/interfaces/IMemeFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IMemeFactory {}\n" - }, - "contracts/interfaces/INonfungiblePositionManager.sol": { - "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Non-fungible token for positions\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\n/// and authorized.\ninterface INonfungiblePositionManager {\n struct MintParams {\n address token0;\n address token1;\n uint24 fee;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n address recipient;\n uint256 deadline;\n }\n\n /// @notice Creates a new position wrapped in a NFT\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\n /// a method does not exist, i.e. the pool is assumed to be initialized.\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\n /// @return tokenId The ID of the token that represents the minted position\n /// @return liquidity The amount of liquidity for this position\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\n function mint(\n MintParams calldata params\n )\n external\n payable\n returns (\n uint256 tokenId,\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n}\n" - }, - "contracts/interfaces/IStratosphere.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IStratosphere {\n function tokenIdOf(address _owner) external view returns (uint256);\n\n function mint() external returns (uint256);\n}\n" - }, - "contracts/interfaces/IVaporDEXFactory.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXFactory {\n function createPair(\n address tokenA,\n address tokenB\n ) external returns (address pair);\n\n function getPair(\n address tokenA,\n address tokenB\n ) external view returns (address pair);\n}\n" - }, - "contracts/interfaces/IVaporDEXRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IVaporDEXRouter {\n function factory() external view returns (address);\n\n function WETH() external view returns (address);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n}\n" - }, - "contracts/MemeFactory.sol": { - "content": "// ███╗░░░███╗███████╗███╗░░░███╗███████╗ ███████╗░█████╗░░█████╗░████████╗░█████╗░██████╗░██╗░░░██╗\n// ████╗░████║██╔════╝████╗░████║██╔════╝ ██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗██╔══██╗╚██╗░██╔╝\n// ██╔████╔██║█████╗░░██╔████╔██║█████╗░░ █████╗░░███████║██║░░╚═╝░░░██║░░░██║░░██║██████╔╝░╚████╔╝░\n// ██║╚██╔╝██║██╔══╝░░██║╚██╔╝██║██╔══╝░░ ██╔══╝░░██╔══██║██║░░██╗░░░██║░░░██║░░██║██╔══██╗░░╚██╔╝░░\n// ██║░╚═╝░██║███████╗██║░╚═╝░██║███████╗ ██║░░░░░██║░░██║╚█████╔╝░░░██║░░░╚█████╔╝██║░░██║░░░██║░░░\n// ╚═╝░░░░░╚═╝╚══════╝╚═╝░░░░░╚═╝╚══════╝ ╚═╝░░░░░╚═╝░░╚═╝░╚════╝░░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝░░░╚═╝░░░\n\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IVaporDEXFactory} from \"./interfaces/IVaporDEXFactory.sol\";\nimport {IVaporDEXRouter} from \"./interfaces/IVaporDEXRouter.sol\";\nimport {Token} from \"./Token.sol\";\nimport {ISablierV2LockupLinear} from \"@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol\";\nimport {LockupLinear} from \"@sablier/v2-core/src/types/DataTypes.sol\";\nimport {IDexAggregator} from \"./interfaces/IDexAggregator.sol\";\nimport {INonfungiblePositionManager} from \"./interfaces/INonfungiblePositionManager.sol\";\n\nerror MemeFactory__WrongConstructorArguments();\nerror MemeFactory__LiquidityLockedOrDepleted();\nerror MemeFactory__Unauthorized();\nerror MemeFactory__ZeroAddress();\nerror MemeFactory__WrongLaunchArguments();\nerror MemeFactory__InsufficientBalance();\nerror MemeFactory__Invalid();\nerror MemeFactory__TranferFailed(address);\nerror MemeFactory__NotEnoughLiquidity();\nerror MemeFactory__MinimumLockDuration();\n\n/// @title MemeFactory\n/// @author Roy & Jose\n/// @notice This contract is used to launch new tokens and create liquidity for them\n/// @dev Utilizes 'Sablier' for liquidity locking\n\ncontract MemeFactory is Ownable {\n //////////////\n /// EVENTS ///\n //////////////\n\n event TokenLaunched(\n address indexed _tokenAddress,\n address indexed _pairAddress,\n bool _liquidityBurned\n );\n\n event StreamCreated(uint256 indexed _streamId);\n event LiquidityBurned(\n address indexed pair,\n address indexed _burner,\n uint256 _amount\n );\n event LiquidityTokensUnlocked(\n address indexed _pairAddress,\n address indexed _receiver\n );\n event LiquidityTransferred(\n address indexed _pairAddress,\n address indexed _to\n );\n event LaunchFeeUpdated(uint256 _newFee);\n event MinimumLiquidityETHUpdated(uint256 _newFee);\n event MinimumLockDurationUpdated(uint40 _newFee);\n event VaporDEXAdapterUpdated(address _newAdapter);\n event AccumulatedFeesWithdrawn(address _to, uint256 _amount);\n\n ///////////////\n /// STORAGE ///\n ///////////////\n address private immutable factory;\n address private immutable router;\n address private immutable stratosphere;\n IDexAggregator private immutable vaporDexAggregator;\n INonfungiblePositionManager private immutable nonFungiblePositionManager;\n IERC20 private immutable WETH;\n IERC20 private immutable USDC;\n IERC20 private immutable VAPE;\n address private vaporDexAdapter;\n address private teamMultisig;\n uint256 private launchFee;\n uint256 public minLiquidityETH;\n uint40 public minLockDuration;\n\n // Sablier\n ISablierV2LockupLinear private immutable sablier;\n // Mapping to store the streamId for each pair and lp owner\n mapping(address => mapping(address => uint256)) private liquidityLocks;\n\n /**\n * @dev MemeFactory constructor initializes the contract with required parameters.\n * @param owner Address of the contract owner.\n * @param routerAddress Address of the VaporDEXRouter contract.\n * @param stratosphereAddress Address of the Stratosphere contract.\n * @param vaporDexAggregator Address of the VaporDEX aggregator.\n * @param vaporDexAdapter Address of the VaporDEX adapter.\n * @param usdc Address of the USDC token.\n * @param vape Address of the VAPE token.\n * @param launchFee Launch fee in USDC.\n * @param uint256 minLiquidityETH;\n * @param uint40 minLockDuration;\n * @param sablier Address of the Sablier contract.\n * @param nonFungiblePositionManager Uni v3 NFT Position Manager\n * @param teamMultisig Multisig address\n */\n struct DeployArgs {\n address owner;\n address routerAddress;\n address stratosphereAddress;\n address vaporDexAggregator;\n address vaporDexAdapter;\n address usdc;\n address vape;\n uint256 launchFee;\n uint256 minLiquidityETH;\n uint40 minLockDuration;\n address sablier;\n address nonFungiblePositionManager;\n address teamMultisig;\n }\n\n /////////////////////////\n ////// CONSTRUCTOR /////\n ////////////////////////\n\n constructor(DeployArgs memory args) Ownable(args.owner) {\n // Check for valid constructor arguments\n if (\n args.owner == address(0) ||\n args.routerAddress == address(0) ||\n args.stratosphereAddress == address(0) ||\n args.vaporDexAggregator == address(0) ||\n args.vaporDexAdapter == address(0) ||\n args.usdc == address(0) ||\n args.launchFee == 0 ||\n args.sablier == address(0) ||\n args.minLiquidityETH == 0 ||\n args.minLockDuration == 0\n ) {\n revert MemeFactory__WrongConstructorArguments();\n }\n\n // Initialize variables\n router = args.routerAddress;\n IVaporDEXRouter _router = IVaporDEXRouter(args.routerAddress);\n factory = _router.factory();\n WETH = IERC20(_router.WETH());\n USDC = IERC20(args.usdc);\n VAPE = IERC20(args.vape);\n minLiquidityETH = args.minLiquidityETH;\n minLockDuration = args.minLockDuration;\n stratosphere = args.stratosphereAddress;\n vaporDexAggregator = IDexAggregator(args.vaporDexAggregator);\n vaporDexAdapter = args.vaporDexAdapter;\n launchFee = args.launchFee;\n sablier = ISablierV2LockupLinear(args.sablier);\n nonFungiblePositionManager = INonfungiblePositionManager(\n args.nonFungiblePositionManager\n );\n teamMultisig = args.teamMultisig;\n }\n\n /**\n * @dev Launches a new token with specified parameters.\n * @param _name Name of the token.\n * @param _symbol Symbol of the token.\n * @param _totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param lockDuration Number of days to lock liquidity for.\n * @param _burnLiquidity Flag indicating whether to burn liquidity or lock it.\n * @return _pair Address of the created token pair.\n * @return _tokenAddress Address of the launched token.\n * @return streamId Stream ID if liquidity is locked, otherwise 0.\n */\n\n function launch(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint256 _tradingStartsAt,\n uint40 lockDuration,\n bool _burnLiquidity\n )\n external\n payable\n returns (address _pair, address _tokenAddress, uint256 streamId)\n {\n uint256 value = msg.value;\n if (value < minLiquidityETH) {\n revert MemeFactory__NotEnoughLiquidity();\n }\n // Step 0: Transfer Fee\n _transferLaunchFee(msg.sender);\n\n // Step 1: Create the token\n Token _token = _createToken(\n _name,\n _symbol,\n _totalSupply,\n _tradingStartsAt,\n address(vaporDexAggregator),\n vaporDexAdapter\n );\n _tokenAddress = address(_token);\n\n // Step 2: Create the pair\n IVaporDEXFactory _factory = IVaporDEXFactory(factory);\n _pair = _factory.createPair(_tokenAddress, address(WETH));\n _token.approve(router, _totalSupply);\n _token.approve(_pair, _totalSupply);\n\n // Step 2: Add Liquidity\n IVaporDEXRouter _router = IVaporDEXRouter(router);\n _router.addLiquidityETH{value: value}(\n _tokenAddress,\n _totalSupply,\n _totalSupply,\n value,\n address(this),\n block.timestamp + 10 minutes\n );\n // Step 3: Get the pair address\n _pair = IVaporDEXFactory(factory).getPair(_tokenAddress, address(WETH));\n if (_pair == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n // Step 4: Set the LP address in the token\n _token.setLiquidityPool(_pair);\n // Step 5: Renounce ownership of the token\n _token.renounceOwnership();\n\n // Step 6: Lock Or Burn Liquidity\n\n IERC20 _lpToken = IERC20(_pair);\n\n if (_burnLiquidity) {\n // Burn Liquidity\n _lpToken.transfer(address(0), _lpToken.balanceOf(address(this)));\n emit LiquidityBurned(\n _pair,\n msg.sender,\n _lpToken.balanceOf(address(this))\n );\n } else {\n if (lockDuration < minLockDuration) {\n revert MemeFactory__MinimumLockDuration();\n }\n _lpToken.approve(\n address(sablier),\n _lpToken.balanceOf(address(this))\n );\n // Lock Liquidity\n // SablierV2\n LockupLinear.CreateWithDurations memory params;\n\n // Declare the function parameters\n params.sender = address(this); // The sender will be able to cancel the stream\n params.recipient = msg.sender; // The recipient of the streamed assets\n params.totalAmount = uint128(_lpToken.balanceOf(address(this))); // Total amount is the amount inclusive of all fees\n params.asset = _lpToken; // The streaming asset\n params.cancelable = false; // Whether the stream will be cancelable or not\n params.transferable = true; // Whether the stream will be transferrable or not\n params.durations = LockupLinear.Durations({\n cliff: lockDuration * 1 days - 1 seconds, // Assets will be unlocked only after the cliff period\n total: lockDuration * 1 days\n });\n\n // Create the stream\n streamId = sablier.createWithDurations(params);\n liquidityLocks[msg.sender][_pair] = streamId;\n\n emit StreamCreated(streamId);\n }\n\n // Step 7: Buy VAPE with USDC on VaporDEXAggregator\n\n _buyVapeWithUsdc(launchFee / 2); // 50% of the launch fee, Admin can change launchFee but this will always be 50% of the launch fee\n\n // Step 8: Add Liquidity on VAPE/USDC Pair VaporDEXV2\n\n _addLiquidityVapeUsdc(); // Uses the balance of VAPE and USDC in the contract\n\n emit TokenLaunched(_tokenAddress, _pair, _burnLiquidity);\n }\n\n /**\n * @dev Unlocks liquidity tokens for the specified pair and recipient.\n * @param _pair Address of the token pair.\n * @param _receiver Address of the recipient of unlocked tokens.\n * @notice It is recommended to direct the user to Sablier UI for better error handling.\n */\n function unlockLiquidityTokens(address _pair, address _receiver) external {\n if (_receiver == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n\n if (streamId == 0) {\n revert MemeFactory__Unauthorized();\n }\n\n uint256 withdrawableAmount = sablier.withdrawableAmountOf(streamId);\n if (withdrawableAmount == 0) {\n revert MemeFactory__LiquidityLockedOrDepleted();\n }\n\n sablier.withdrawMax({streamId: streamId, to: _receiver}); // Other reverts are handled by Sablier\n\n emit LiquidityTokensUnlocked(_pair, _receiver);\n }\n\n /**\n * @dev Transfers the locked liquidity to the specified recipient for the given pair.\n * @param _pair Address of the token pair.\n * @param _to Address of the recipient.\n */\n function transferLock(address _pair, address _to) external {\n uint256 streamId = liquidityLocks[msg.sender][_pair];\n if (\n streamId == 0 ||\n _to == address(0) ||\n sablier.isTransferable(streamId) == false\n ) {\n revert MemeFactory__Unauthorized();\n }\n\n liquidityLocks[_to][_pair] = streamId;\n liquidityLocks[msg.sender][_pair] = 0;\n\n sablier.transferFrom({from: msg.sender, to: _to, tokenId: streamId}); // Other reverts are handled by Sablier\n\n emit LiquidityTransferred(_pair, _to);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _liquidity New liquidity.\n */\n\n function setMinimumLiquidityETH(uint256 _liquidity) external onlyOwner {\n if (_liquidity == 0) {\n revert MemeFactory__Invalid();\n }\n minLiquidityETH = _liquidity;\n emit MinimumLiquidityETHUpdated(_liquidity);\n }\n\n /**\n * @dev Sets the minimum liquidity for creating new tokens.\n * @param _lockDuration New lock duration in days.\n */\n\n function setMinLockDuration(uint40 _lockDuration) external onlyOwner {\n if (_lockDuration == 0) {\n revert MemeFactory__Invalid();\n }\n minLockDuration = _lockDuration;\n emit MinimumLockDurationUpdated(_lockDuration);\n }\n\n /**\n * @dev Sets the launch fee for creating new tokens.\n * @param _launchFee New launch fee in USDC.\n */\n\n function setLaunchFee(uint256 _launchFee) external onlyOwner {\n if (_launchFee == 0) {\n revert MemeFactory__Invalid();\n }\n launchFee = _launchFee;\n emit LaunchFeeUpdated(_launchFee);\n }\n\n /**\n * @dev Sets the VaporDEX adapter address.\n * @param _vaporDexAdapter New VaporDEX adapter address.\n */\n\n function setVaporDEXAdapter(address _vaporDexAdapter) external onlyOwner {\n if (\n _vaporDexAdapter == vaporDexAdapter ||\n _vaporDexAdapter == address(0)\n ) {\n revert MemeFactory__Invalid();\n }\n vaporDexAdapter = _vaporDexAdapter;\n emit VaporDEXAdapterUpdated(_vaporDexAdapter);\n }\n\n /**\n * @dev Withdraws any remaining USDC fees to the specified address.\n * @param _to Address to which the remaining fees are withdrawn.\n */\n\n function withdrawFee(address _to) external onlyOwner {\n if (_to == address(0)) {\n revert MemeFactory__ZeroAddress();\n }\n IERC20 _usdc = IERC20(USDC);\n _usdc.transfer(_to, _usdc.balanceOf(address(this)));\n emit AccumulatedFeesWithdrawn(_to, _usdc.balanceOf(address(this)));\n }\n\n /**\n * @dev Creates a new Token contract with specified parameters.\n * @param name Name of the token.\n * @param symbol Symbol of the token.\n * @param totalSupply Total supply of the token.\n * @param _tradingStartsAt Timestamp when trading starts for the token.\n * @param dexAggregator Address of the decentralized exchange aggregator.\n * @param dexAdapter Address of the decentralized exchange adapter.\n * @return _token Instance of the created Token contract.\n */\n function _createToken(\n string memory name,\n string memory symbol,\n uint256 totalSupply,\n uint256 _tradingStartsAt,\n address dexAggregator,\n address dexAdapter\n ) internal returns (Token _token) {\n if (totalSupply == 0 || _tradingStartsAt < block.timestamp + 2 days) {\n revert MemeFactory__WrongLaunchArguments();\n }\n _token = new Token(\n name,\n symbol,\n totalSupply,\n stratosphere,\n address(this),\n _tradingStartsAt,\n dexAggregator,\n dexAdapter\n );\n }\n\n /**\n * @dev Transfers the launch fee in USDC from the sender.\n * @param _from Address from which the launch fee is transferred.\n */\n\n function _transferLaunchFee(address _from) internal {\n IERC20 _usdc = IERC20(USDC);\n if (_usdc.balanceOf(_from) < launchFee) {\n revert MemeFactory__InsufficientBalance();\n }\n bool isSuccess = _usdc.transferFrom(_from, address(this), launchFee);\n if (!isSuccess) {\n revert MemeFactory__TranferFailed(_from);\n }\n }\n\n /**\n * @dev Buys VAPE with USDC on VaporDEXAggregator\n * @param amountIn Amount of USDC to be used for buying VAPE.\n */\n\n function _buyVapeWithUsdc(uint256 amountIn) internal {\n USDC.approve(address(vaporDexAggregator), amountIn);\n\n IDexAggregator.FormattedOffer memory offer = vaporDexAggregator\n .findBestPath(\n amountIn,\n address(USDC),\n address(VAPE),\n 1 // can be changed to 3\n );\n IDexAggregator.Trade memory trade;\n trade.amountIn = amountIn;\n trade.amountOut = offer.amounts[offer.amounts.length - 1];\n trade.path = offer.path;\n trade.adapters = offer.adapters;\n vaporDexAggregator.swapNoSplit(trade, address(this), 0);\n }\n\n /**\n * @dev Adds liquidity for VAPE/USDC pair on VaporDEXV2.\n * @notice Uses the balance of VAPE and USDC in the contract.\n */\n\n function _addLiquidityVapeUsdc() internal {\n uint256 amountInUSDC = USDC.balanceOf(address(this));\n uint256 amountInVAPE = VAPE.balanceOf(address(this));\n USDC.approve(address(nonFungiblePositionManager), amountInUSDC);\n VAPE.approve(address(nonFungiblePositionManager), amountInVAPE);\n INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager\n .MintParams({\n token0: address(VAPE),\n token1: address(USDC),\n fee: 3000,\n tickLower: -887220, // full range\n tickUpper: 887220, // full range\n amount0Desired: amountInVAPE,\n amount1Desired: amountInUSDC,\n amount0Min: amountInVAPE - _percentage(amountInVAPE, 200), // 2% slippage\n amount1Min: amountInUSDC - _percentage(amountInUSDC, 200), // 2% slippage\n recipient: teamMultisig,\n deadline: block.timestamp + 2 minutes\n });\n nonFungiblePositionManager.mint(mintParams);\n\n // Q: What checks should be done with the return values?\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n\n // Getters\n\n /**\n * @dev Returns the launch fee.\n * @return uint256 The launch fee.\n */\n function getLaunchFee() external view returns (uint256) {\n return launchFee;\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDexAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the VaporDEX router.\n * @return address The address of the VaporDEX router.\n */\n function getVaporDEXRouter() external view returns (address) {\n return router;\n }\n\n /**\n * @dev Returns the address of the VaporDEX factory.\n * @return address The address of the VaporDEX factory.\n */\n function getVaporDEXFactory() external view returns (address) {\n return factory;\n }\n\n /**\n * @dev Returns the address of the Stratosphere contract.\n * @return address The address of the Stratosphere contract.\n */\n function getStratosphere() external view returns (address) {\n return stratosphere;\n }\n\n /**\n * @dev Returns the address of the VaporDEX aggregator.\n * @return address The address of the VaporDEX aggregator.\n */\n function getVaporDexAggregator() external view returns (address) {\n return address(vaporDexAggregator);\n }\n\n /**\n * @dev Returns the address of the USDC token.\n * @return address The address of the USDC token.\n */\n function getUSDC() external view returns (address) {\n return address(USDC);\n }\n\n /**\n * @dev Returns the address of the VAPE token.\n * @return address The address of the VAPE token.\n */\n function getVAPE() external view returns (address) {\n return address(VAPE);\n }\n\n /**\n * @dev Returns the address of the VaporDEX adapter.\n * @return address The address of the VaporDEX adapter.\n */\n function getVaporDEXAdapter() external view returns (address) {\n return vaporDexAdapter;\n }\n\n /**\n * @dev Returns the address of the team multisig wallet.\n * @return address The address of the team multisig wallet.\n */\n function getTeamMultisig() external view returns (address) {\n return teamMultisig;\n }\n\n /**\n * @dev Returns the address of the Sablier contract.\n * @return address The address of the Sablier contract.\n */\n function getSablier() external view returns (address) {\n return address(sablier);\n }\n\n /**\n * @dev Returns the address of the NonFungiblePositionManager contract.\n * @return address The address of the NonFungiblePositionManager contract.\n */\n function getNonFungiblePositionManager() external view returns (address) {\n return address(nonFungiblePositionManager);\n }\n\n /**\n * @dev Returns the liquidity lock for the specified pair and owner.\n * @param _pair Address of the token pair.\n * @param _owner Address of the owner.\n * @return uint256 Stream ID for the liquidity lock.\n */\n\n function getLiquidityLock(\n address _pair,\n address _owner\n ) external view returns (uint256) {\n return liquidityLocks[_owner][_pair];\n }\n}\n" - }, - "contracts/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ERC20Permit} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IStratosphere} from \"./interfaces/IStratosphere.sol\";\n\nerror Token__MissingLiquidityPool();\nerror Token__ExceedsMaximumHolding();\nerror Token__TradingNotStarted();\nerror Token__NonStratosphereNFTHolder();\nerror Token__BotDetected();\n\ncontract Token is ERC20, ERC20Permit, Ownable {\n address public liquidityPool;\n address public immutable dexAggregator;\n address public immutable dexAdapter;\n uint256 public immutable maxHoldingAmount;\n uint256 public immutable tradingStartsAt;\n IStratosphere public immutable stratosphere;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _supply,\n address _stratosphereAddress,\n address _owner,\n uint256 _tradingStartsAt,\n address _dexAggregator,\n address _dexAdapter\n ) ERC20(_name, _symbol) ERC20Permit(_name) Ownable(_owner) {\n stratosphere = IStratosphere(_stratosphereAddress);\n _mint(msg.sender, _supply);\n maxHoldingAmount = _percentage(_supply, 100); // 1% of total supply\n tradingStartsAt = _tradingStartsAt;\n dexAggregator = _dexAggregator;\n dexAdapter = _dexAdapter;\n }\n\n function setLiquidityPool(address _liquidityPool) external onlyOwner {\n if (_liquidityPool == address(0)) {\n revert Token__MissingLiquidityPool();\n }\n liquidityPool = _liquidityPool;\n }\n\n /// @dev Replacement for _beforeTokenTransfer() since OZ v5\n function _update(\n address from,\n address to,\n uint256 value\n ) internal virtual override {\n super._update(from, to, value);\n uint256 _tradingStartsAt = tradingStartsAt;\n\n if (liquidityPool == address(0)) {\n require(\n from == owner() || to == owner(),\n \"Patience - Trading Not Started Yet!\"\n );\n return;\n }\n\n if (block.timestamp < _tradingStartsAt) {\n revert Token__TradingNotStarted();\n }\n\n uint256 _secondsSinceTradingStarted = block.timestamp -\n _tradingStartsAt;\n\n if (_secondsSinceTradingStarted > 24 hours) {\n return;\n }\n\n if (_secondsSinceTradingStarted < 1 hours) {\n _enforceAntiWhale(to, value);\n if (!(_isStratosphereMemberOrAdmin(from) && _isStratosphereMemberOrAdmin(to))) {\n revert Token__NonStratosphereNFTHolder();\n }\n } else if (_secondsSinceTradingStarted < 24 hours) {\n _enforceAntiWhale(to, value);\n }\n }\n\n function _enforceAntiWhale(address to, uint256 value) internal view {\n if (to != liquidityPool) {\n uint256 newBalance = balanceOf(to) + value;\n if (newBalance > maxHoldingAmount) {\n revert Token__ExceedsMaximumHolding();\n }\n }\n }\n\n function _isStratosphereMemberOrAdmin(address _address) internal view returns (bool pass) {\n if (_address == dexAggregator || _address == dexAdapter || stratosphere.tokenIdOf(_address) != 0 ||\n _address == liquidityPool) {\n pass = true;\n }\n }\n\n function _percentage(\n uint256 _number,\n uint256 _percentageBasisPoints // Example: 1% is 100\n ) internal pure returns (uint256) {\n return (_number * _percentageBasisPoints) / 10_000;\n }\n}\n" - } - }, - "settings": { - "evmVersion": "paris", - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index 331411b..2817956 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -1,10 +1,11 @@ import "dotenv/config"; import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; -import "hardhat-deploy"; + +import "./tasks/verify"; const deployerKey = process.env.DEPLOYER_KEY || ""; -const accounts = [deployerKey]; +const accounts = deployerKey ? [deployerKey] : []; const config: HardhatUserConfig = { etherscan: { @@ -22,7 +23,7 @@ const config: HardhatUserConfig = { }, }, { - network: "snowtrace", + network: "snowtrace-fuji", chainId: 43113, urls: { apiURL: @@ -32,11 +33,6 @@ const config: HardhatUserConfig = { }, ], }, - namedAccounts: { - deployer: { - default: 0, - }, - }, solidity: { version: "0.8.25", settings: { diff --git a/package.json b/package.json index 2539f1c..e8d09b5 100644 --- a/package.json +++ b/package.json @@ -8,18 +8,24 @@ "build": "hardhat compile", "clean": "hardhat clean", "test": "hardhat test", - "deploy:fuji": "hardhat deploy --network avalancheFuji --tags TokenFactory" + "deploy:fuji": "hardhat run --network avalancheFuji scripts/deploy/index.ts", + "deploy:avalanche": "hardhat run --network avalanche scripts/deploy/index.ts" }, "dependencies": { "@openzeppelin/contracts": "^5.0.1", "@prb/math": "^4.0.2", "@sablier/v2-core": "^1.1.2", - "@sablier/v2-periphery": "^1.1.1" + "@sablier/v2-periphery": "^1.1.1", + "@uniswap/v2-core": "^1.0.1", + "@uniswap/v2-periphery": "1.1.0-beta.0", + "solmate": "6.2.0" }, "devDependencies": { "@nomicfoundation/hardhat-toolbox": "^4.0.0", + "abitype": "^1.0.2", "dotenv": "^16.3.1", "ds-test": "github:dapphub/ds-test", + "ethers": "6.6.2", "forge-std": "github:foundry-rs/forge-std#v1", "hardhat": "^2.19.3", "hardhat-deploy": "^0.11.45" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8238753..6a03de1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,17 +17,32 @@ dependencies: '@sablier/v2-periphery': specifier: ^1.1.1 version: 1.1.1(@sablier/v2-core@1.1.2) + '@uniswap/v2-core': + specifier: ^1.0.1 + version: 1.0.1 + '@uniswap/v2-periphery': + specifier: 1.1.0-beta.0 + version: 1.1.0-beta.0 + solmate: + specifier: 6.2.0 + version: 6.2.0 devDependencies: '@nomicfoundation/hardhat-toolbox': specifier: ^4.0.0 - version: 4.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.6)(@nomicfoundation/hardhat-ethers@3.0.5)(@nomicfoundation/hardhat-network-helpers@1.0.10)(@nomicfoundation/hardhat-verify@2.0.5)(@typechain/ethers-v6@0.5.1)(@typechain/hardhat@9.1.0)(@types/chai@4.3.14)(@types/mocha@10.0.6)(@types/node@20.12.4)(chai@4.4.1)(ethers@6.11.1)(hardhat-gas-reporter@1.0.10)(hardhat@2.22.2)(solidity-coverage@0.8.11)(ts-node@10.9.2)(typechain@8.3.2)(typescript@5.4.4) + version: 4.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.6)(@nomicfoundation/hardhat-ethers@3.0.5)(@nomicfoundation/hardhat-network-helpers@1.0.10)(@nomicfoundation/hardhat-verify@2.0.5)(@typechain/ethers-v6@0.5.1)(@typechain/hardhat@9.1.0)(@types/chai@4.3.14)(@types/mocha@10.0.6)(@types/node@20.12.4)(chai@4.4.1)(ethers@6.6.2)(hardhat-gas-reporter@1.0.10)(hardhat@2.22.2)(solidity-coverage@0.8.11)(ts-node@10.9.2)(typechain@8.3.2)(typescript@5.4.4) + abitype: + specifier: ^1.0.2 + version: 1.0.2(typescript@5.4.4) dotenv: specifier: ^16.3.1 version: 16.4.5 ds-test: specifier: github:dapphub/ds-test version: github.com/dapphub/ds-test/e282159d5170298eb2455a6c05280ab5a73a4ef0 + ethers: + specifier: 6.6.2 + version: 6.6.2 forge-std: specifier: github:foundry-rs/forge-std#v1 version: github.com/foundry-rs/forge-std/bb4ceea94d6f10eeb5b41dc2391c6c8bf8e734ef @@ -40,8 +55,8 @@ devDependencies: packages: - /@adraffy/ens-normalize@1.10.1: - resolution: {integrity: sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==} + /@adraffy/ens-normalize@1.9.2: + resolution: {integrity: sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==} dev: true /@cspotcode/source-map-support@0.8.1: @@ -413,25 +428,18 @@ packages: tweetnacl-util: 0.15.1 dev: true - /@noble/curves@1.2.0: - resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} - dependencies: - '@noble/hashes': 1.3.2 - dev: true - /@noble/curves@1.3.0: resolution: {integrity: sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA==} dependencies: '@noble/hashes': 1.3.3 dev: true - /@noble/hashes@1.2.0: - resolution: {integrity: sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==} + /@noble/hashes@1.1.2: + resolution: {integrity: sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==} dev: true - /@noble/hashes@1.3.2: - resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} - engines: {node: '>= 16'} + /@noble/hashes@1.2.0: + resolution: {integrity: sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==} dev: true /@noble/hashes@1.3.3: @@ -602,7 +610,7 @@ packages: ethereum-cryptography: 0.1.3 dev: true - /@nomicfoundation/hardhat-chai-matchers@2.0.6(@nomicfoundation/hardhat-ethers@3.0.5)(chai@4.4.1)(ethers@6.11.1)(hardhat@2.22.2): + /@nomicfoundation/hardhat-chai-matchers@2.0.6(@nomicfoundation/hardhat-ethers@3.0.5)(chai@4.4.1)(ethers@6.6.2)(hardhat@2.22.2): resolution: {integrity: sha512-Te1Uyo9oJcTCF0Jy9dztaLpshmlpjLf2yPtWXlXuLjMt3RRSmJLm/+rKVTW6gfadAEs12U/it6D0ZRnnRGiICQ==} peerDependencies: '@nomicfoundation/hardhat-ethers': ^3.0.0 @@ -610,24 +618,24 @@ packages: ethers: ^6.1.0 hardhat: ^2.9.4 dependencies: - '@nomicfoundation/hardhat-ethers': 3.0.5(ethers@6.11.1)(hardhat@2.22.2) + '@nomicfoundation/hardhat-ethers': 3.0.5(ethers@6.6.2)(hardhat@2.22.2) '@types/chai-as-promised': 7.1.8 chai: 4.4.1 chai-as-promised: 7.1.1(chai@4.4.1) deep-eql: 4.1.3 - ethers: 6.11.1 + ethers: 6.6.2 hardhat: 2.22.2(ts-node@10.9.2)(typescript@5.4.4) ordinal: 1.0.3 dev: true - /@nomicfoundation/hardhat-ethers@3.0.5(ethers@6.11.1)(hardhat@2.22.2): + /@nomicfoundation/hardhat-ethers@3.0.5(ethers@6.6.2)(hardhat@2.22.2): resolution: {integrity: sha512-RNFe8OtbZK6Ila9kIlHp0+S80/0Bu/3p41HUpaRIoHLm6X3WekTd83vob3rE54Duufu1edCiBDxspBzi2rxHHw==} peerDependencies: ethers: ^6.1.0 hardhat: ^2.0.0 dependencies: debug: 4.3.4(supports-color@8.1.1) - ethers: 6.11.1 + ethers: 6.6.2 hardhat: 2.22.2(ts-node@10.9.2)(typescript@5.4.4) lodash.isequal: 4.5.0 transitivePeerDependencies: @@ -643,7 +651,7 @@ packages: hardhat: 2.22.2(ts-node@10.9.2)(typescript@5.4.4) dev: true - /@nomicfoundation/hardhat-toolbox@4.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.6)(@nomicfoundation/hardhat-ethers@3.0.5)(@nomicfoundation/hardhat-network-helpers@1.0.10)(@nomicfoundation/hardhat-verify@2.0.5)(@typechain/ethers-v6@0.5.1)(@typechain/hardhat@9.1.0)(@types/chai@4.3.14)(@types/mocha@10.0.6)(@types/node@20.12.4)(chai@4.4.1)(ethers@6.11.1)(hardhat-gas-reporter@1.0.10)(hardhat@2.22.2)(solidity-coverage@0.8.11)(ts-node@10.9.2)(typechain@8.3.2)(typescript@5.4.4): + /@nomicfoundation/hardhat-toolbox@4.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.6)(@nomicfoundation/hardhat-ethers@3.0.5)(@nomicfoundation/hardhat-network-helpers@1.0.10)(@nomicfoundation/hardhat-verify@2.0.5)(@typechain/ethers-v6@0.5.1)(@typechain/hardhat@9.1.0)(@types/chai@4.3.14)(@types/mocha@10.0.6)(@types/node@20.12.4)(chai@4.4.1)(ethers@6.6.2)(hardhat-gas-reporter@1.0.10)(hardhat@2.22.2)(solidity-coverage@0.8.11)(ts-node@10.9.2)(typechain@8.3.2)(typescript@5.4.4): resolution: {integrity: sha512-jhcWHp0aHaL0aDYj8IJl80v4SZXWMS1A2XxXa1CA6pBiFfJKuZinCkO6wb+POAt0LIfXB3gA3AgdcOccrcwBwA==} peerDependencies: '@nomicfoundation/hardhat-chai-matchers': ^2.0.0 @@ -664,17 +672,17 @@ packages: typechain: ^8.3.0 typescript: '>=4.5.0' dependencies: - '@nomicfoundation/hardhat-chai-matchers': 2.0.6(@nomicfoundation/hardhat-ethers@3.0.5)(chai@4.4.1)(ethers@6.11.1)(hardhat@2.22.2) - '@nomicfoundation/hardhat-ethers': 3.0.5(ethers@6.11.1)(hardhat@2.22.2) + '@nomicfoundation/hardhat-chai-matchers': 2.0.6(@nomicfoundation/hardhat-ethers@3.0.5)(chai@4.4.1)(ethers@6.6.2)(hardhat@2.22.2) + '@nomicfoundation/hardhat-ethers': 3.0.5(ethers@6.6.2)(hardhat@2.22.2) '@nomicfoundation/hardhat-network-helpers': 1.0.10(hardhat@2.22.2) '@nomicfoundation/hardhat-verify': 2.0.5(hardhat@2.22.2) - '@typechain/ethers-v6': 0.5.1(ethers@6.11.1)(typechain@8.3.2)(typescript@5.4.4) - '@typechain/hardhat': 9.1.0(@typechain/ethers-v6@0.5.1)(ethers@6.11.1)(hardhat@2.22.2)(typechain@8.3.2) + '@typechain/ethers-v6': 0.5.1(ethers@6.6.2)(typechain@8.3.2)(typescript@5.4.4) + '@typechain/hardhat': 9.1.0(@typechain/ethers-v6@0.5.1)(ethers@6.6.2)(hardhat@2.22.2)(typechain@8.3.2) '@types/chai': 4.3.14 '@types/mocha': 10.0.6 '@types/node': 20.12.4 chai: 4.4.1 - ethers: 6.11.1 + ethers: 6.6.2 hardhat: 2.22.2(ts-node@10.9.2)(typescript@5.4.4) hardhat-gas-reporter: 1.0.10(hardhat@2.22.2) solidity-coverage: 0.8.11(hardhat@2.22.2) @@ -969,21 +977,21 @@ packages: resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} dev: true - /@typechain/ethers-v6@0.5.1(ethers@6.11.1)(typechain@8.3.2)(typescript@5.4.4): + /@typechain/ethers-v6@0.5.1(ethers@6.6.2)(typechain@8.3.2)(typescript@5.4.4): resolution: {integrity: sha512-F+GklO8jBWlsaVV+9oHaPh5NJdd6rAKN4tklGfInX1Q7h0xPgVLP39Jl3eCulPB5qexI71ZFHwbljx4ZXNfouA==} peerDependencies: ethers: 6.x typechain: ^8.3.2 typescript: '>=4.7.0' dependencies: - ethers: 6.11.1 + ethers: 6.6.2 lodash: 4.17.21 ts-essentials: 7.0.3(typescript@5.4.4) typechain: 8.3.2(typescript@5.4.4) typescript: 5.4.4 dev: true - /@typechain/hardhat@9.1.0(@typechain/ethers-v6@0.5.1)(ethers@6.11.1)(hardhat@2.22.2)(typechain@8.3.2): + /@typechain/hardhat@9.1.0(@typechain/ethers-v6@0.5.1)(ethers@6.6.2)(hardhat@2.22.2)(typechain@8.3.2): resolution: {integrity: sha512-mtaUlzLlkqTlfPwB3FORdejqBskSnh+Jl8AIJGjXNAQfRQ4ofHADPl1+oU7Z3pAJzmZbUXII8MhOLQltcHgKnA==} peerDependencies: '@typechain/ethers-v6': ^0.5.1 @@ -991,8 +999,8 @@ packages: hardhat: ^2.9.9 typechain: ^8.3.2 dependencies: - '@typechain/ethers-v6': 0.5.1(ethers@6.11.1)(typechain@8.3.2)(typescript@5.4.4) - ethers: 6.11.1 + '@typechain/ethers-v6': 0.5.1(ethers@6.6.2)(typechain@8.3.2)(typescript@5.4.4) + ethers: 6.6.2 fs-extra: 9.1.0 hardhat: 2.22.2(ts-node@10.9.2)(typescript@5.4.4) typechain: 8.3.2(typescript@5.4.4) @@ -1089,10 +1097,47 @@ packages: '@types/node': 20.12.4 dev: true + /@uniswap/lib@1.1.1: + resolution: {integrity: sha512-2yK7sLpKIT91TiS5sewHtOa7YuM8IuBXVl4GZv2jZFys4D2sY7K5vZh6MqD25TPA95Od+0YzCVq6cTF2IKrOmg==} + engines: {node: '>=10'} + dev: false + + /@uniswap/v2-core@1.0.0: + resolution: {integrity: sha512-BJiXrBGnN8mti7saW49MXwxDBRFiWemGetE58q8zgfnPPzQKq55ADltEILqOt6VFZ22kVeVKbF8gVd8aY3l7pA==} + engines: {node: '>=10'} + dev: false + + /@uniswap/v2-core@1.0.1: + resolution: {integrity: sha512-MtybtkUPSyysqLY2U210NBDeCHX+ltHt3oADGdjqoThZaFRDKwM6k1Nb3F0A3hk5hwuQvytFWhrWHOEq6nVJ8Q==} + engines: {node: '>=10'} + dev: false + + /@uniswap/v2-periphery@1.1.0-beta.0: + resolution: {integrity: sha512-6dkwAMKza8nzqYiXEr2D86dgW3TTavUvCR0w2Tu33bAbM8Ah43LKAzH7oKKPRT5VJQaMi1jtkGs1E8JPor1n5g==} + engines: {node: '>=10'} + dependencies: + '@uniswap/lib': 1.1.1 + '@uniswap/v2-core': 1.0.0 + dev: false + /abbrev@1.0.9: resolution: {integrity: sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==} dev: true + /abitype@1.0.2(typescript@5.4.4): + resolution: {integrity: sha512-aFt4k2H+eiAKy/zxtnORa9iIb10BMBeWL18l8v4+QuwYEBXPxxjSB1bFZCzQmKPoj8m7j68K705l3uY+E2gAjg==} + peerDependencies: + typescript: '>=5.0.4' + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + dependencies: + typescript: 5.4.4 + dev: true + /acorn-walk@8.3.2: resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} engines: {node: '>=0.4.0'} @@ -1991,13 +2036,13 @@ packages: - utf-8-validate dev: true - /ethers@6.11.1: - resolution: {integrity: sha512-mxTAE6wqJQAbp5QAe/+o+rXOID7Nw91OZXvgpjDa1r4fAbq2Nu314oEZSbjoRLacuCzs7kUC3clEvkCQowffGg==} + /ethers@6.6.2: + resolution: {integrity: sha512-vyWfVAj2g7xeZIivOqlbpt7PbS2MzvJkKgsncgn4A/1xZr8Q3BznBmEBRQyPXKCgHmX4PzRQLpnYG7jl/yutMg==} engines: {node: '>=14.0.0'} dependencies: - '@adraffy/ens-normalize': 1.10.1 - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 + '@adraffy/ens-normalize': 1.9.2 + '@noble/hashes': 1.1.2 + '@noble/secp256k1': 1.7.1 '@types/node': 18.15.13 aes-js: 4.0.0-beta.5 tslib: 2.4.0 @@ -3502,6 +3547,10 @@ packages: web3-utils: 1.10.4 dev: true + /solmate@6.2.0: + resolution: {integrity: sha512-AM38ioQ2P8zRsA42zenb9or6OybRjOLXIu3lhIT8rhddUuduCt76pUEuLxOIg9GByGojGz+EbpFdCB6B+QZVVA==} + dev: false + /source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} dependencies: diff --git a/remappings.txt b/remappings.txt index 3150a6e..3a6015d 100644 --- a/remappings.txt +++ b/remappings.txt @@ -8,4 +8,6 @@ ds-test/=node_modules/ds-test/src/ @sablier/v2-periphery=node_modules/@sablier/v2-periphery/ @openzeppelin/contracts/=node_modules/@openzeppelin/contracts/ @prb/math/=node_modules/@prb/math/ -@uniswap/v3-periphery=node_modules/@uniswap/v3-periphery/ \ No newline at end of file +solmate/=node_modules/solmate/ +@uniswap/=node_modules/@uniswap/ + diff --git a/scripts/deploy/diamond.ts b/scripts/deploy/diamond.ts new file mode 100644 index 0000000..a73a241 --- /dev/null +++ b/scripts/deploy/diamond.ts @@ -0,0 +1,81 @@ +import { BaseContract, Contract, encodeBytes32String } from "ethers"; +import { ethers, network } from "hardhat"; +import { addFacets } from "../../utils/diamond"; +import { deployContract } from "../../utils/deployContract"; +import { DiamondInit } from "../../typechain-types"; +import getFacets from "../../utils/getFacets"; +import { addresses, chainNameToId, config } from "../../config"; +import type { ChainName } from "../../config"; + +const chain = (network.name || "avalancheFuji") as ChainName; + +/// @dev IMPORTANT: Order matters here. +export const defaultArgs: DiamondInit.DeployArgsStruct = { + routerAddress: addresses.vaporDexRouter[chain], + factoryAddress: addresses.vaporDexFactory[chain], + stratosphereAddress: addresses.stratosphereNFT[chain], + vaporDexAggregator: addresses.vaporDexAggregatorRouter[chain], + vaporDexAdapter: addresses.vaporDexAggregatorAdapter[chain], + usdc: addresses.usdc[chain], + vape: addresses.vape[chain], + weth: addresses.weth[chain], + launchFee: config.launchFeeUSDC[chain], + minLiquidityETH: config.minimumNative[chain], + minLockDuration: config.minimumLockDuration[chain], + sablier: addresses.sablier[chain], + nonFungiblePositionManager: addresses.nonFungiblePositionManager[chain], + teamMultisig: addresses.teamMultiSig[chain], + slippage: config.slippage[chain], +}; + +export const FacetNames = getFacets(); + +export async function deployDiamond( + args: DiamondInit.DeployArgsStruct = defaultArgs +) { + const [deployer] = await ethers.getSigners(); + // Deploy DiamondCutFacet + const diamondCutFacet = await deployContract("DiamondCutFacet"); + + // Deploy Diamond + const diamond = await deployContract("TokenFactoryDiamond", { + args: [deployer.address, await diamondCutFacet.getAddress()], + log: true, + // skipIfAlreadyDeployed: true, + useCreate3Factory: true, + salt: encodeBytes32String("VaporFi_TokenFactoryDiamond"), + }); + const diamondAddress = await diamond.getAddress(); + + // Deploy DiamondInit + const diamondInit = await deployContract("DiamondInit"); + const diamondInitAddress = await diamondInit.getAddress(); + + // Deploy Facets + const facets: BaseContract[] = []; + const facetsByName = {} as { + [K in (typeof FacetNames)[number]]: BaseContract; + }; + for (const FacetName of FacetNames) { + const facet = (await deployContract(FacetName)) as any; + + facets.push(facet); + facetsByName[FacetName] = facet; + } + + // Add facets to diamond + const functionCall = diamondInit.interface.encodeFunctionData("init", [ + Object.values(args), + ]); + + await addFacets(facets, diamondAddress, diamondInitAddress, functionCall); + + // Transfer ownership to multisig + const ownershipFacet = await ethers.getContractAt( + "OwnershipFacet", + diamondAddress + ); + await ownershipFacet.transferOwnership(addresses.teamMultiSig[chain]); + + return diamond; +} diff --git a/scripts/deploy/index.ts b/scripts/deploy/index.ts new file mode 100644 index 0000000..bd9ac1e --- /dev/null +++ b/scripts/deploy/index.ts @@ -0,0 +1,14 @@ +import { deployDiamond } from "./diamond"; + +async function main() { + await deployDiamond(); +} + +main() + .then(() => { + console.log("Deployment complete"); + }) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/upgrade-diamond.ts b/scripts/upgrade-diamond.ts new file mode 100644 index 0000000..b880074 --- /dev/null +++ b/scripts/upgrade-diamond.ts @@ -0,0 +1,31 @@ +import { network } from "hardhat"; +import TokenFactoryDiamond from "../deployments/TokenFactoryDiamond.json"; +import { deployContract } from "../utils/deployContract"; +import { addOrReplaceFacets } from "../utils/diamond"; +import getFacets from "../utils/getFacets"; + +async function main() { + console.log("💎 Upgrading diamond"); + const diamondAddress = + TokenFactoryDiamond[network.name as keyof typeof TokenFactoryDiamond] + .address; + + // Deploy Facets + const FacetNames = getFacets(["DiamondCutFacet", "DiamondLoupeFacet"]); + + const Facets = []; + for (const name of FacetNames) { + Facets.push(await deployContract(name)); + } + + // Do diamond cut + await addOrReplaceFacets(Facets, diamondAddress); + console.log("✅ Diamond upgraded"); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/tasks/verify.ts b/tasks/verify.ts new file mode 100644 index 0000000..15b6925 --- /dev/null +++ b/tasks/verify.ts @@ -0,0 +1,51 @@ +import { task } from "hardhat/config"; +import getContractDeployed from "../utils/getContractDeployment"; +import getFacets from "../utils/getFacets"; + +task("verify:contract", "Verifies a contract on etherscan") + .addParam("contract", "The contract name") + .setAction(async (taskArgs, hre) => { + const { contract } = taskArgs; + const { network } = hre; + + const { address, args } = await getContractDeployed(contract, network.name); + + try { + await hre.run("verify:verify", { + address: address, + constructorArguments: args, + }); + } catch (err) { + console.log(err); + return; + } + }); + +task("verify:facets", "Verifies all facets on etherscan").setAction( + async (taskArgs, hre) => { + const { network } = hre; + + const facets = getFacets([]); // empty array to omit no facets + + for (const facet of facets) { + const { address, args } = await getContractDeployed(facet, network.name); + + try { + await hre.run("verify:verify", { + address: address, + constructorArguments: args, + }); + } catch (err) { + console.log(err); + continue; + } + } + } +); + +task("verify:all", "Verifies all contracts on etherscan").setAction( + async (taskArgs, hre) => { + await hre.run("verify:contract", { contract: "TokenFactoryDiamond" }); + await hre.run("verify:facets"); + } +); diff --git a/test/Token.t.sol b/test/Token.t.sol index 01030b5..e5df0be 100644 --- a/test/Token.t.sol +++ b/test/Token.t.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.22; -import {TokenFactoryTest, IERC20, Test} from "./TokenFactory.t.sol"; +import {TokenFactoryTest, IERC20} from "./TokenFactory.t.sol"; import {IDexAggregator} from "../contracts/interfaces/IDexAggregator.sol"; import "forge-std/console.sol"; import {IStratosphere} from "../contracts/interfaces/IStratosphere.sol"; -import {Token__NonStratosphereNFTHolder, Token__TradingNotStarted, Token__ExceedsMaximumHolding} from "../contracts/Token.sol"; +import {ERC20Token__NonStratosphereNFTHolder, ERC20Token__TradingNotStarted, ERC20Token__ExceedsMaximumHolding} from "../contracts/tokens/ERC20Token.sol"; contract TokenTest is TokenFactoryTest { IERC20 public token; diff --git a/test/TokenFactory.t.sol b/test/TokenFactory.t.sol index 5fe8384..1e0bd00 100644 --- a/test/TokenFactory.t.sol +++ b/test/TokenFactory.t.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.22; -import "forge-std/Test.sol"; -import "contracts/TokenFactory.sol"; import {ISablierV2LockupLinear} from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; import {LockupLinear} from "@sablier/v2-core/src/types/DataTypes.sol"; import {ERC20Mock} from "./mocks/ERC20Mock.sol"; @@ -10,15 +8,27 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {LockupLinear} from "@sablier/v2-core/src/types/DataTypes.sol"; import {IUniswapV3PoolState} from "./interfaces/IUniswapV3PoolState.sol"; -contract TokenFactoryTest is Test { - TokenFactory tokenFactory; - address _owner = makeAddr("owner"); +import {TokenFactoryDiamondBaseTest} from "./TokenFactoryDiamondBase.t.sol"; +import {TokenFactoryDiamond} from "contracts/TokenFactoryDiamond.sol"; +import {DiamondInit} from "contracts/upgradeInitializers/DiamondInit.sol"; +import {AdminFacet} from "contracts/facets/AdminFacet.sol"; +import {LaunchERC20Facet} from "contracts/facets/LaunchERC20Facet.sol"; +import {LiquidityLockFacet} from "contracts/facets/LiquidityLockFacet.sol"; + +contract TokenFactoryTest is TokenFactoryDiamondBaseTest { + TokenFactoryDiamond tokenFactory; + AdminFacet internal adminFacet; + LaunchERC20Facet internal launchFacet; + LiquidityLockFacet internal liquidityLockFacet; + address _teamMultiSig = makeAddr("teamMultiSig"); address _router = 0x19C0FC4562A4b76F27f86c676eF5a7e38D12a20d; + address _factory = 0xC009a670E2B02e21E7e75AE98e254F467f7ae257; address _stratosphere = 0x08e287adCf9BF6773a87e1a278aa9042BEF44b60; address _vaporDexAggregator = 0x55477d8537ede381784b448876AfAa98aa450E63; address _vaporDexAdapter = 0x01e5C45cB25E30860c2Fb80369A9C27628911a2b; address _vape = 0x7bddaF6DbAB30224AA2116c4291521C7a60D5f55; + address _weth = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7; address _liquidityPositionManager = 0xC967b23826DdAB00d9AAd3702CbF5261B7Ed9a3a; IERC20 _usdc = IERC20(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E); // real USDC @@ -41,28 +51,36 @@ contract TokenFactoryTest is Test { function setUp() public { vm.createSelectFork("https://api.avax.network/ext/bc/C/rpc"); + vm.deal(_user, 10000000 ether); vm.deal(_jose, 10000000 ether); vm.deal(_hitesh, 10000000 ether); vm.deal(_roy, 10000000 ether); - vm.startPrank(_owner); - TokenFactory.DeployArgs memory args = TokenFactory.DeployArgs({ - owner: _owner, - routerAddress: _router, - stratosphereAddress: _stratosphere, - vaporDexAggregator: _vaporDexAggregator, - vaporDexAdapter: _vaporDexAdapter, - usdc: address(_usdc), - vape: _vape, - launchFee: launchFee, - minLiquidityETH: minimumLiquidityETH, - minLockDuration: minlockDuration, - sablier: address(sablier), - nonFungiblePositionManager: _liquidityPositionManager, - teamMultisig: address(_teamMultiSig), - slippage: slippage - }); - tokenFactory = new TokenFactory(args); + + vm.startPrank(_diamondOwner); + + DiamondInit.DeployArgs memory _initArgs; + _initArgs.routerAddress = _router; + _initArgs.factoryAddress = _factory; + _initArgs.stratosphereAddress = _stratosphere; + _initArgs.vaporDexAggregator = _vaporDexAggregator; + _initArgs.vaporDexAdapter = _vaporDexAdapter; + _initArgs.vape = _vape; + _initArgs.usdc = address(_usdc); + _initArgs.weth = _weth; + _initArgs.launchFee = launchFee; + _initArgs.minLiquidityETH = minimumLiquidityETH; + _initArgs.minLockDuration = minlockDuration; + _initArgs.sablier = address(sablier); + _initArgs.nonFungiblePositionManager = _liquidityPositionManager; + _initArgs.teamMultisig = _teamMultiSig; + _initArgs.slippage = slippage; + + tokenFactory = createDiamond(_initArgs); + adminFacet = AdminFacet(address(tokenFactory)); + launchFacet = LaunchERC20Facet(address(tokenFactory)); + liquidityLockFacet = LiquidityLockFacet(address(tokenFactory)); + vm.stopPrank(); } @@ -76,12 +94,12 @@ contract TokenFactoryTest is Test { function test_Revert_MinimumLiquidityETH() public { vm.startPrank(_user); - uint256 launchFeeContract = tokenFactory.getLaunchFee(); + uint256 launchFeeContract = adminFacet.getLaunchFee(); _usdc.approve(address(tokenFactory), launchFeeContract); vm.expectRevert(); - tokenFactory.launch{value: minimumLiquidityETH - 1}( + launchFacet.launchERC20{value: minimumLiquidityETH - 1}( "Test Token", "TEST", 1_000_000 ether, @@ -96,14 +114,14 @@ contract TokenFactoryTest is Test { function test_Revert_SetMinimumLiquidityETH() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setMinimumLiquidityETH(3 ether); + adminFacet.setMinimumLiquidityETH(3 ether); vm.stopPrank(); } function test_Revert_SetMinimumLockDuration() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setMinLockDuration(30); + adminFacet.setMinLockDuration(30); vm.stopPrank(); } @@ -123,9 +141,14 @@ contract TokenFactoryTest is Test { // Pair and Token Checks assertTrue(_pair != address(0), "Pair address is zero"); assertTrue(_tokenAddress != address(0), "Token address is zero"); - assertTrue(IERC20(_pair).balanceOf(address(0)) > minimumLiquidity); assertTrue( - vapeUsdcPoolLiquidityAfterLaunch > vapeUsdcPoolLiquidityBeforeLaunch + IERC20(_pair).balanceOf(address(0)) > minimumLiquidity, + "Pair balance is zero" + ); + assertTrue( + vapeUsdcPoolLiquidityAfterLaunch > + vapeUsdcPoolLiquidityBeforeLaunch, + "Liquidity not added to pool" ); // Stream Checks @@ -137,12 +160,12 @@ contract TokenFactoryTest is Test { function test_Revert_LaunchWithLPLock() public { vm.startPrank(_user); - uint256 launchFeeContract = tokenFactory.getLaunchFee(); + uint256 launchFeeContract = adminFacet.getLaunchFee(); _usdc.approve(address(tokenFactory), launchFeeContract); vm.expectRevert(); - tokenFactory.launch{value: minimumLiquidityETH}( + launchFacet.launchERC20{value: minimumLiquidityETH}( "Test Token", "TEST", 1_000_000 ether, @@ -206,7 +229,7 @@ contract TokenFactoryTest is Test { uint256 withdrawableAmount = sablier.withdrawableAmountOf(_streamId); assertTrue(withdrawableAmount > 0); - tokenFactory.unlockLiquidityTokens(_tokenAddress, address(_user)); + liquidityLockFacet.unlockLiquidityTokens(_tokenAddress, address(_user)); assertTrue( IERC20(_pair).balanceOf(address(_user)) == withdrawableAmount ); @@ -237,7 +260,7 @@ contract TokenFactoryTest is Test { assertTrue(sablier.withdrawableAmountOf(_streamId) == 0); sablier.approve(address(tokenFactory), _streamId); - tokenFactory.transferLock(_tokenAddress, address(_jose)); + liquidityLockFacet.transferLock(_tokenAddress, address(_jose)); address ownerOfStream = sablier.ownerOf(_streamId); assertTrue(ownerOfStream == address(_jose)); @@ -262,17 +285,15 @@ contract TokenFactoryTest is Test { vm.warp(block.timestamp + lockDuration * 1 days); sablier.approve(address(tokenFactory), _streamId); - tokenFactory.transferLock(_tokenAddress, address(_jose)); + liquidityLockFacet.transferLock(_tokenAddress, _jose); address ownerOfStream = sablier.ownerOf(_streamId); - assertTrue(ownerOfStream == address(_jose)); + assertTrue(ownerOfStream == _jose); vm.stopPrank(); vm.startPrank(_jose); uint256 withdrawableAmount = sablier.withdrawableAmountOf(_streamId); - tokenFactory.unlockLiquidityTokens(_tokenAddress, address(_jose)); - assertTrue( - IERC20(_pair).balanceOf(address(_jose)) == withdrawableAmount - ); + liquidityLockFacet.unlockLiquidityTokens(_tokenAddress, _jose); + assertTrue(IERC20(_pair).balanceOf(_jose) == withdrawableAmount); LockupLinear.Stream memory stream = sablier.getStream(_streamId); assertEq(stream.isDepleted, true); @@ -284,34 +305,34 @@ contract TokenFactoryTest is Test { } function test_ChangeLaunchFee_Withdraw_Owner() public { - vm.startPrank(_owner); - assertEq(tokenFactory.getLaunchFee(), launchFee); + vm.startPrank(_diamondOwner); + assertEq(adminFacet.getLaunchFee(), launchFee); uint256 newLaunchFee = 500 * 1e6; - tokenFactory.setLaunchFee(newLaunchFee); - assertEq(tokenFactory.getLaunchFee(), newLaunchFee); + adminFacet.setLaunchFee(newLaunchFee); + assertEq(adminFacet.getLaunchFee(), newLaunchFee); vm.stopPrank(); } function test_SetVaporDexAdapter_Owner() public { - vm.startPrank(_owner); - assertEq(tokenFactory.getVaporDEXAdapter(), _vaporDexAdapter); + vm.startPrank(_diamondOwner); + assertEq(adminFacet.getVaporDEXAdapter(), _vaporDexAdapter); address newAdapter = makeAddr("newAdapter"); - tokenFactory.setVaporDEXAdapter(newAdapter); - assertEq(tokenFactory.getVaporDEXAdapter(), newAdapter); + adminFacet.setVaporDEXAdapter(newAdapter); + assertEq(adminFacet.getVaporDEXAdapter(), newAdapter); vm.stopPrank(); } function test_Revert_ChangeLaunchFee_NotOwner() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setLaunchFee(500 * 1e6); + adminFacet.setLaunchFee(500 * 1e6); vm.stopPrank(); } function test_Revert_SetVaporDexAdapter_NotOwner() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setVaporDEXAdapter(makeAddr("newAdapter")); + adminFacet.setVaporDEXAdapter(makeAddr("newAdapter")); vm.stopPrank(); } @@ -321,11 +342,11 @@ contract TokenFactoryTest is Test { uint256 value, uint40 lockDuration ) internal returns (address pair, address tokenAddress, uint256 streamId) { - uint256 launchFeeContract = tokenFactory.getLaunchFee(); + uint256 launchFeeContract = adminFacet.getLaunchFee(); _usdc.approve(address(tokenFactory), launchFeeContract); - (address _pair, address _tokenAddress, uint256 _streamId) = tokenFactory - .launch{value: value}( + (address _pair, address _tokenAddress, uint256 _streamId) = launchFacet + .launchERC20{value: value}( "Test Token", "TEST", 1_000_000 ether, diff --git a/test/TokenFactoryDiamondBase.t.sol b/test/TokenFactoryDiamondBase.t.sol new file mode 100644 index 0000000..3011c05 --- /dev/null +++ b/test/TokenFactoryDiamondBase.t.sol @@ -0,0 +1,154 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity ^0.8.25; + +import {Test} from "forge-std/Test.sol"; +import {IDiamondCut} from "contracts/interfaces/IDiamondCut.sol"; + +import {TokenFactoryDiamond} from "contracts/TokenFactoryDiamond.sol"; +import {DiamondCutFacet} from "contracts/facets/DiamondCutFacet.sol"; +import {DiamondLoupeFacet} from "contracts/facets/DiamondLoupeFacet.sol"; +import {OwnershipFacet} from "contracts/facets/OwnershipFacet.sol"; +import {AuthorizationFacet} from "contracts/facets/AuthorizationFacet.sol"; +import {DiamondInit} from "contracts/upgradeInitializers/DiamondInit.sol"; +import {LaunchERC20Facet} from "contracts/facets/LaunchERC20Facet.sol"; +import {AdminFacet} from "contracts/facets/AdminFacet.sol"; +import {LiquidityLockFacet} from "contracts/facets/LiquidityLockFacet.sol"; + +contract TokenFactoryDiamondBaseTest is Test { + IDiamondCut.FacetCut[] internal _cut; + address internal _diamondOwner = makeAddr("diamondOwner"); + + function createDiamond( + DiamondInit.DeployArgs memory _initArgs + ) internal returns (TokenFactoryDiamond) { + DiamondCutFacet diamondCut = new DiamondCutFacet(); + TokenFactoryDiamond diamond = new TokenFactoryDiamond( + _diamondOwner, + address(diamondCut) + ); + DiamondInit diamondInit = new DiamondInit(); + + setDiamondLoupeFacet(); + setOwnershipFacet(); + setAuthorizationFacet(); + setLaunchERC20Facet(); + setAdminFacet(); + setLiquidityLockFacet(); + + bytes memory data = abi.encodeWithSelector( + DiamondInit.init.selector, + _initArgs + ); + DiamondCutFacet(address(diamond)).diamondCut( + _cut, + address(diamondInit), + data + ); + + delete _cut; + return diamond; + } + + function setDiamondLoupeFacet() private { + DiamondLoupeFacet diamondLoupe = new DiamondLoupeFacet(); + bytes4[] memory functionSelectors; + functionSelectors = new bytes4[](5); + functionSelectors[0] = DiamondLoupeFacet + .facetFunctionSelectors + .selector; + functionSelectors[1] = DiamondLoupeFacet.facets.selector; + functionSelectors[2] = DiamondLoupeFacet.facetAddress.selector; + functionSelectors[3] = DiamondLoupeFacet.facetAddresses.selector; + functionSelectors[4] = DiamondLoupeFacet.supportsInterface.selector; + _cut.push( + IDiamondCut.FacetCut({ + facetAddress: address(diamondLoupe), + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: functionSelectors + }) + ); + } + + function setOwnershipFacet() private { + OwnershipFacet ownership = new OwnershipFacet(); + bytes4[] memory functionSelectors; + functionSelectors = new bytes4[](2); + functionSelectors[0] = OwnershipFacet.owner.selector; + functionSelectors[1] = OwnershipFacet.transferOwnership.selector; + _cut.push( + IDiamondCut.FacetCut({ + facetAddress: address(ownership), + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: functionSelectors + }) + ); + } + + function setAuthorizationFacet() private { + AuthorizationFacet authorization = new AuthorizationFacet(); + bytes4[] memory functionSelectors; + functionSelectors = new bytes4[](3); + functionSelectors[0] = AuthorizationFacet.authorized.selector; + functionSelectors[1] = AuthorizationFacet.authorize.selector; + functionSelectors[2] = AuthorizationFacet.unAuthorize.selector; + _cut.push( + IDiamondCut.FacetCut({ + facetAddress: address(authorization), + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: functionSelectors + }) + ); + } + + function setLaunchERC20Facet() private { + LaunchERC20Facet launchERC20 = new LaunchERC20Facet(); + bytes4[] memory functionSelectors; + functionSelectors = new bytes4[](1); + functionSelectors[0] = LaunchERC20Facet.launchERC20.selector; + _cut.push( + IDiamondCut.FacetCut({ + facetAddress: address(launchERC20), + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: functionSelectors + }) + ); + } + + function setAdminFacet() private { + AdminFacet admin = new AdminFacet(); + bytes4[] memory functionSelectors; + functionSelectors = new bytes4[](8); + functionSelectors[0] = AdminFacet.setMinimumLiquidityETH.selector; + functionSelectors[1] = AdminFacet.setSlippage.selector; + functionSelectors[2] = AdminFacet.setMinLockDuration.selector; + functionSelectors[3] = AdminFacet.setLaunchFee.selector; + functionSelectors[4] = AdminFacet.setVaporDEXAdapter.selector; + functionSelectors[5] = AdminFacet.emergencyWithdraw.selector; + functionSelectors[6] = AdminFacet.getLaunchFee.selector; + functionSelectors[7] = AdminFacet.getVaporDEXAdapter.selector; + _cut.push( + IDiamondCut.FacetCut({ + facetAddress: address(admin), + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: functionSelectors + }) + ); + } + + function setLiquidityLockFacet() private { + LiquidityLockFacet liquidityLock = new LiquidityLockFacet(); + bytes4[] memory functionSelectors; + functionSelectors = new bytes4[](2); + functionSelectors[0] = LiquidityLockFacet + .unlockLiquidityTokens + .selector; + functionSelectors[1] = LiquidityLockFacet.transferLock.selector; + _cut.push( + IDiamondCut.FacetCut({ + facetAddress: address(liquidityLock), + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: functionSelectors + }) + ); + } +} diff --git a/test/TokenFactoryFuji.t.sol b/test/TokenFactoryFuji.t.sol index 50b2584..33019c5 100644 --- a/test/TokenFactoryFuji.t.sol +++ b/test/TokenFactoryFuji.t.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.22; -import "forge-std/Test.sol"; -import "contracts/TokenFactory.sol"; import {ISablierV2LockupLinear} from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; import {LockupLinear} from "@sablier/v2-core/src/types/DataTypes.sol"; import {ERC20Mock} from "./mocks/ERC20Mock.sol"; @@ -10,15 +8,27 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {LockupLinear} from "@sablier/v2-core/src/types/DataTypes.sol"; import {IUniswapV3PoolState} from "./interfaces/IUniswapV3PoolState.sol"; -contract TokenFactoryTest is Test { - TokenFactory tokenFactory; - address _owner = makeAddr("owner"); +import {TokenFactoryDiamondBaseTest} from "./TokenFactoryDiamondBase.t.sol"; +import {TokenFactoryDiamond} from "contracts/TokenFactoryDiamond.sol"; +import {DiamondInit} from "contracts/upgradeInitializers/DiamondInit.sol"; +import {AdminFacet} from "contracts/facets/AdminFacet.sol"; +import {LaunchERC20Facet} from "contracts/facets/LaunchERC20Facet.sol"; +import {LiquidityLockFacet} from "contracts/facets/LiquidityLockFacet.sol"; + +contract TokenFactoryFujiTest is TokenFactoryDiamondBaseTest { + TokenFactoryDiamond tokenFactory; + AdminFacet internal adminFacet; + LaunchERC20Facet internal launchFacet; + LiquidityLockFacet internal liquidityLockFacet; + address _teamMultiSig = makeAddr("teamMultiSig"); address _router = 0x19C0FC4562A4b76F27f86c676eF5a7e38D12a20d; + address _factory = 0xC009a670E2B02e21E7e75AE98e254F467f7ae257; address _stratosphere = 0x65eB37AeB1F2a9cE39556F80044607dD969b0336; address _vaporDexAggregator = 0x55477d8537ede381784b448876AfAa98aa450E63; address _vaporDexAdapter = 0x3F1aF4D92c91511A0BCe4B21bc256bF63bcab470; address _vape = 0x3bD01B76BB969ef2D5103b5Ea84909AD8d345663; + address _weth = 0xd00ae08403B9bbb9124bB305C09058E32C39A48c; address _liquidityPositionManager = 0x7a0A7C4273B25b3a71Daeaa387c7855081AC4E56; IERC20 _usdc = IERC20(0xeA42E3030ab1406a0b6aAd077Caa927673a2c302); // real USDC @@ -26,7 +36,7 @@ contract TokenFactoryTest is Test { IUniswapV3PoolState(0xb1ca210D7429584eF3B50cD32B564b4f72b9D07c); // VAPE/USDC Pool ISablierV2LockupLinear sablier = ISablierV2LockupLinear(0xebf7ed508a0Bb1c4e66b9E6F8C6a73342E7049ac); - // Addresses that hold USDC on mainnet + // Addresses that hold USDC on testnet address _user = 0xbbE2B49D637629280543d9550bceB80bF802287e; address _jose = 0xbbE2B49D637629280543d9550bceB80bF802287e; address _hitesh = 0xbbE2B49D637629280543d9550bceB80bF802287e; @@ -41,28 +51,36 @@ contract TokenFactoryTest is Test { function setUp() public { vm.createSelectFork("https://rpc.ankr.com/avalanche_fuji"); + vm.deal(_user, 10000000 ether); vm.deal(_jose, 10000000 ether); vm.deal(_hitesh, 10000000 ether); vm.deal(_roy, 10000000 ether); - vm.startPrank(_owner); - TokenFactory.DeployArgs memory args = TokenFactory.DeployArgs({ - owner: _owner, - routerAddress: _router, - stratosphereAddress: _stratosphere, - vaporDexAggregator: _vaporDexAggregator, - vaporDexAdapter: _vaporDexAdapter, - usdc: address(_usdc), - vape: _vape, - launchFee: launchFee, - minLiquidityETH: minimumLiquidityETH, - minLockDuration: minlockDuration, - sablier: address(sablier), - nonFungiblePositionManager: _liquidityPositionManager, - teamMultisig: address(_teamMultiSig), - slippage: slippage - }); - tokenFactory = new TokenFactory(args); + + vm.startPrank(_diamondOwner); + + DiamondInit.DeployArgs memory _initArgs; + _initArgs.routerAddress = _router; + _initArgs.factoryAddress = _factory; + _initArgs.stratosphereAddress = _stratosphere; + _initArgs.vaporDexAggregator = _vaporDexAggregator; + _initArgs.vaporDexAdapter = _vaporDexAdapter; + _initArgs.vape = _vape; + _initArgs.usdc = address(_usdc); + _initArgs.weth = _weth; + _initArgs.launchFee = launchFee; + _initArgs.minLiquidityETH = minimumLiquidityETH; + _initArgs.minLockDuration = minlockDuration; + _initArgs.sablier = address(sablier); + _initArgs.nonFungiblePositionManager = _liquidityPositionManager; + _initArgs.teamMultisig = _teamMultiSig; + _initArgs.slippage = slippage; + + tokenFactory = createDiamond(_initArgs); + adminFacet = AdminFacet(address(tokenFactory)); + launchFacet = LaunchERC20Facet(address(tokenFactory)); + liquidityLockFacet = LiquidityLockFacet(address(tokenFactory)); + vm.stopPrank(); } @@ -76,12 +94,12 @@ contract TokenFactoryTest is Test { function test_Revert_MinimumLiquidityETH() public { vm.startPrank(_user); - uint256 launchFeeContract = tokenFactory.getLaunchFee(); + uint256 launchFeeContract = adminFacet.getLaunchFee(); _usdc.approve(address(tokenFactory), launchFeeContract); vm.expectRevert(); - tokenFactory.launch{value: minimumLiquidityETH - 1}( + launchFacet.launchERC20{value: minimumLiquidityETH - 1}( "Test Token", "TEST", 1_000_000 ether, @@ -96,14 +114,14 @@ contract TokenFactoryTest is Test { function test_Revert_SetMinimumLiquidityETH() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setMinimumLiquidityETH(3 ether); + adminFacet.setMinimumLiquidityETH(3 ether); vm.stopPrank(); } function test_Revert_SetMinimumLockDuration() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setMinLockDuration(30); + adminFacet.setMinLockDuration(30); vm.stopPrank(); } @@ -143,12 +161,12 @@ contract TokenFactoryTest is Test { function test_Revert_LaunchWithLPLock() public { vm.startPrank(_user); - uint256 launchFeeContract = tokenFactory.getLaunchFee(); + uint256 launchFeeContract = adminFacet.getLaunchFee(); _usdc.approve(address(tokenFactory), launchFeeContract); vm.expectRevert(); - tokenFactory.launch{value: minimumLiquidityETH}( + launchFacet.launchERC20{value: minimumLiquidityETH}( "Test Token", "TEST", 1_000_000 ether, @@ -212,7 +230,7 @@ contract TokenFactoryTest is Test { uint256 withdrawableAmount = sablier.withdrawableAmountOf(_streamId); assertTrue(withdrawableAmount > 0); - tokenFactory.unlockLiquidityTokens(_tokenAddress, address(_user)); + liquidityLockFacet.unlockLiquidityTokens(_tokenAddress, address(_user)); assertTrue( IERC20(_pair).balanceOf(address(_user)) == withdrawableAmount ); @@ -243,7 +261,7 @@ contract TokenFactoryTest is Test { assertTrue(sablier.withdrawableAmountOf(_streamId) == 0); sablier.approve(address(tokenFactory), _streamId); - tokenFactory.transferLock(_tokenAddress, address(_jose)); + liquidityLockFacet.transferLock(_tokenAddress, address(_jose)); address ownerOfStream = sablier.ownerOf(_streamId); assertTrue(ownerOfStream == address(_jose)); @@ -268,17 +286,15 @@ contract TokenFactoryTest is Test { vm.warp(block.timestamp + lockDuration * 1 days); sablier.approve(address(tokenFactory), _streamId); - tokenFactory.transferLock(_tokenAddress, address(_jose)); + liquidityLockFacet.transferLock(_tokenAddress, _jose); address ownerOfStream = sablier.ownerOf(_streamId); - assertTrue(ownerOfStream == address(_jose)); + assertTrue(ownerOfStream == _jose); vm.stopPrank(); vm.startPrank(_jose); uint256 withdrawableAmount = sablier.withdrawableAmountOf(_streamId); - tokenFactory.unlockLiquidityTokens(_tokenAddress, address(_jose)); - assertTrue( - IERC20(_pair).balanceOf(address(_jose)) == withdrawableAmount - ); + liquidityLockFacet.unlockLiquidityTokens(_tokenAddress, _jose); + assertTrue(IERC20(_pair).balanceOf(_jose) == withdrawableAmount); LockupLinear.Stream memory stream = sablier.getStream(_streamId); assertEq(stream.isDepleted, true); @@ -290,34 +306,34 @@ contract TokenFactoryTest is Test { } function test_ChangeLaunchFee_Withdraw_Owner() public { - vm.startPrank(_owner); - assertEq(tokenFactory.getLaunchFee(), launchFee); + vm.startPrank(_diamondOwner); + assertEq(adminFacet.getLaunchFee(), launchFee); uint256 newLaunchFee = 500 * 1e6; - tokenFactory.setLaunchFee(newLaunchFee); - assertEq(tokenFactory.getLaunchFee(), newLaunchFee); + adminFacet.setLaunchFee(newLaunchFee); + assertEq(adminFacet.getLaunchFee(), newLaunchFee); vm.stopPrank(); } function test_SetVaporDexAdapter_Owner() public { - vm.startPrank(_owner); - assertEq(tokenFactory.getVaporDEXAdapter(), _vaporDexAdapter); + vm.startPrank(_diamondOwner); + assertEq(adminFacet.getVaporDEXAdapter(), _vaporDexAdapter); address newAdapter = makeAddr("newAdapter"); - tokenFactory.setVaporDEXAdapter(newAdapter); - assertEq(tokenFactory.getVaporDEXAdapter(), newAdapter); + adminFacet.setVaporDEXAdapter(newAdapter); + assertEq(adminFacet.getVaporDEXAdapter(), newAdapter); vm.stopPrank(); } function test_Revert_ChangeLaunchFee_NotOwner() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setLaunchFee(500 * 1e6); + adminFacet.setLaunchFee(500 * 1e6); vm.stopPrank(); } function test_Revert_SetVaporDexAdapter_NotOwner() public { vm.startPrank(_user); vm.expectRevert(); - tokenFactory.setVaporDEXAdapter(makeAddr("newAdapter")); + adminFacet.setVaporDEXAdapter(makeAddr("newAdapter")); vm.stopPrank(); } @@ -327,11 +343,11 @@ contract TokenFactoryTest is Test { uint256 value, uint40 lockDuration ) internal returns (address pair, address tokenAddress, uint256 streamId) { - uint256 launchFeeContract = tokenFactory.getLaunchFee(); + uint256 launchFeeContract = adminFacet.getLaunchFee(); _usdc.approve(address(tokenFactory), launchFeeContract); - (address _pair, address _tokenAddress, uint256 _streamId) = tokenFactory - .launch{value: value}( + (address _pair, address _tokenAddress, uint256 _streamId) = launchFacet + .launchERC20{value: value}( "Test Token", "TEST", 1_000_000 ether, diff --git a/utils/chunk.ts b/utils/chunk.ts new file mode 100644 index 0000000..9bf78a8 --- /dev/null +++ b/utils/chunk.ts @@ -0,0 +1,9 @@ +const chunk = (input: any[], size: number) => { + return input.reduce((arr: any[], item: any, idx: number) => { + return idx % size === 0 + ? [...arr, [item]] + : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]] + }, []) +} + +export default chunk diff --git a/utils/deployContract.ts b/utils/deployContract.ts new file mode 100644 index 0000000..c9c88ee --- /dev/null +++ b/utils/deployContract.ts @@ -0,0 +1,158 @@ +import * as fs from "node:fs"; +import * as process from "node:process"; +import { artifacts, network, ethers } from "hardhat"; +import { type Artifact } from "hardhat/types"; +import { saveDeployment } from "./saveDeployment"; +import { addresses } from "../config"; + +export type DeployOptions = { + args?: any[]; + log?: boolean; + skipIfAlreadyDeployed?: boolean; + useCreate3Factory?: boolean; + salt?: string; +}; + +export const defaultDeployOptions: DeployOptions = { + args: [], + log: true, + skipIfAlreadyDeployed: process.env.FORCE_DEPLOY === undefined, + useCreate3Factory: false, + salt: "", +}; + +export async function deployContract( + contractName: string, + options: DeployOptions = defaultDeployOptions +) { + const deploymentOptions = { + ...defaultDeployOptions, + ...options, + }; + + const networkName = network.name; + const artifact = await artifacts.readArtifact(contractName); + + console.log("deployContract", { + contractName, + deploymentOptions, + networkName: network.name, + }); + + if (deploymentOptions.skipIfAlreadyDeployed) { + // Load previous deployment if exists + const previousDeployment = await loadPreviousDeployment( + contractName, + artifact + ); + + if (previousDeployment) { + console.log( + `Contract ${contractName} already deployed at ${await previousDeployment.getAddress()}` + ); + return previousDeployment; + } + } + const Contract = await ethers.getContractFactory(contractName); + + let contract; + let contractAddress = ""; + if (deploymentOptions.useCreate3Factory) { + // @ts-expect-error + if (addresses.create3Factory[networkName] === undefined) { + throw new Error( + `CREATE3Factory address not defined for network ${networkName}` + ); + } + + if (!deploymentOptions.salt) { + throw new Error("Must provide salt if using CREATE3Factory"); + } + + const CREATE3Factory = await ethers.getContractAt( + "CREATE3Factory", + // @ts-expect-error + addresses.create3Factory[networkName] + ); + const salt = deploymentOptions.salt; + const creationCode = ethers.solidityPacked( + ["bytes", "bytes"], + [ + Contract.bytecode, + Contract.interface.encodeDeploy(deploymentOptions.args ?? []), + ] + ); + await CREATE3Factory.deploy(salt, creationCode); + const [deployer] = await ethers.getSigners(); + const addressGenerated = await CREATE3Factory.getDeployed.staticCallResult( + deployer.address, + salt + ); + contractAddress = addressGenerated[0]; + contract = await ethers.getContractAt(contractName, contractAddress); + } else { + console.log("Deploying", contractName, "with args", deploymentOptions.args); + contract = await ethers.deployContract( + contractName, + deploymentOptions.args ? deploymentOptions.args : [] + ); + console.log("Waiting for deployment"); + await contract.waitForDeployment(); + console.log("Deployment complete"); + contractAddress = await contract.getAddress(); + } + + saveDeployment( + contractName, + { artifact, options: deploymentOptions, address: contractAddress }, + networkName + ); + + if (deploymentOptions.log) { + console.log(`${contractName} deployed to:`, contractAddress); + } + + return contract; +} + +async function loadPreviousDeployment( + contractName: string, + artifact: Artifact +) { + const networkName = network.name; + const dirName = "deployments"; + const dirPath = `${process.cwd()}/${dirName}`; + const filePath = `${dirPath}/${contractName}.json`; + + if (!fs.existsSync(filePath)) { + return null; + } + + const previousDeployment = JSON.parse( + fs.readFileSync(filePath, { encoding: "utf-8" }) + ); + + if (previousDeployment[networkName] === undefined) { + console.log( + `Contract ${contractName} not deployed on network ${networkName}` + ); + return null; + } + + // If contract is already deployed, return it + if (previousDeployment[networkName].artifact.bytecode === artifact.bytecode) { + console.log("Contract's bytecode is the same, reusing previous deployment"); + const contract = await ethers.getContractAt( + contractName, + previousDeployment[networkName].address + ); + + console.log( + `Contract ${contractName} already deployed at ${await contract.getAddress()}` + ); + + return contract; + } + + return null; +} diff --git a/utils/diamond.ts b/utils/diamond.ts new file mode 100644 index 0000000..2bc0d4a --- /dev/null +++ b/utils/diamond.ts @@ -0,0 +1,178 @@ +import { + BaseContract, + Contract, + ZeroAddress, + Fragment, + FunctionFragment, +} from 'ethers' +import { ethers } from 'hardhat' +import { IDiamondLoupe } from '../typechain-types' + +export type FacetCut = { + facetAddress: string + action: number + functionSelectors: string[] +} + +export enum FacetCutAction { + Add = 0, + Replace = 1, + Remove = 2, +} + +export function getSelectors(contract: BaseContract): string[] { + const selectors: string[] = [] + contract.interface.forEachFunction((func) => { + selectors.push(func.selector) + }) + return selectors +} + +export async function addOrReplaceFacets( + facets: BaseContract[], + diamondAddress: string, + initContract: string = ZeroAddress, + initData = '0x' +): Promise { + const loupe = ( + await ethers.getContractAt('IDiamondLoupe', diamondAddress) + ) + + const cut = [] + for (const f of facets) { + const replaceSelectors = [] + const addSelectors = [] + const facetAddress = await f.getAddress() + + const selectors = getSelectors(f) + + for (const s of selectors) { + const addr = await loupe.facetAddress(s.toString()) + + if (addr === ZeroAddress) { + addSelectors.push(s) + continue + } + + if (addr.toLowerCase() !== (await f.getAddress()).toLowerCase()) { + replaceSelectors.push(s) + } + } + + if (replaceSelectors.length) { + cut.push({ + facetAddress, + action: FacetCutAction.Replace, + functionSelectors: replaceSelectors, + }) + } + if (addSelectors.length) { + cut.push({ + facetAddress, + action: FacetCutAction.Add, + functionSelectors: addSelectors, + }) + } + } + + if (!cut.length) { + console.log('No facets to add or replace.') + return + } + + console.log('Adding/Replacing facet(s)...', diamondAddress, cut) + await doCut(diamondAddress, cut, initContract, initData) + + console.log('Done.') +} + +export async function addFacets( + facets: BaseContract[], + diamondAddress: string, + initContract: string = ZeroAddress, + initData = '0x' +): Promise { + const cut = [] + for (const f of facets) { + const selectors = getSelectors(f) + const facetAddress = await f.getAddress() + + cut.push({ + facetAddress, + action: FacetCutAction.Add, + functionSelectors: selectors, + }) + } + + if (!cut.length) { + console.log('No facets to add or replace.') + return + } + + console.log('Adding facet(s)...') + await doCut(diamondAddress, cut, initContract, initData) + + console.log('Done.') +} + +export async function removeFacet( + selectors: string[], + diamondAddress: string +): Promise { + const cut = [ + { + facetAddress: ZeroAddress, + action: FacetCutAction.Remove, + functionSelectors: selectors, + }, + ] + + console.log('Removing facet...') + await doCut(diamondAddress, cut, ZeroAddress, '0x') + + console.log('Done.') +} + +export async function replaceFacet( + facet: Contract, + diamondAddress: string, + initContract: string = ZeroAddress, + initData = '0x' +): Promise { + const selectors = getSelectors(facet) + + const cut = [ + { + facetAddress: facet.address, + action: FacetCutAction.Replace, + functionSelectors: selectors, + }, + ] + + console.log('Replacing facet...') + await doCut(diamondAddress, cut, initContract, initData) + + console.log('Done.') +} + +async function doCut( + diamondAddress: string, + cut: any[], + initContract: string, + initData: string +): Promise { + const cutter = await ethers.getContractAt('DiamondCutFacet', diamondAddress) + console.log('Cutting diamond...') + + console.log( + '🚀 ~ file: diamond.ts:168 ~ cut, initContract, initData:', + cut, + initContract, + initData + ) + const tx = await cutter.diamondCut(cut, initContract, initData) + const receipt = await tx.wait() + if (!receipt?.status) { + throw Error(`Diamond upgrade failed: ${tx.data}`) + } +} diff --git a/utils/generateFullAbi.ts b/utils/generateFullAbi.ts new file mode 100644 index 0000000..2ef5d60 --- /dev/null +++ b/utils/generateFullAbi.ts @@ -0,0 +1,39 @@ +import fs from "fs"; +import path from "path"; +import { artifacts } from "hardhat"; +import type { AbiItemType } from "abitype"; + +async function generateFullAbi(): Promise { + const excludedFacets: string[] = ["DiamondCutFacet", "DiamondLoupeFacet"]; + const facetsPath = path.join(__dirname, "../artifacts/contracts/facets"); + const facets: string[] = fs + .readdirSync(facetsPath) + .map((file) => file.replace(path.extname(file), "")); + const abis: AbiItemType[] = []; + + for (const facet of facets) { + if (excludedFacets.includes(facet)) { + continue; + } + const abi = (await artifacts.readArtifact(facet)).abi; + abis.push(...abi); + } + + const uniqueAbis: AbiItemType[] = Array.from( + new Set(abis.map((item) => JSON.stringify(item))) + ).map((item) => JSON.parse(item)); + const dir = path.join(__dirname, "../abi"); + + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + + fs.writeFileSync( + path.join(dir, "diamondAbi.ts"), + `export const diamondAbi = ${JSON.stringify(uniqueAbis, null, 2)} as const;` + ); + + return uniqueAbis; +} + +generateFullAbi().then(() => process.exit(0)); diff --git a/utils/getContractDeployment.ts b/utils/getContractDeployment.ts new file mode 100644 index 0000000..688e1d3 --- /dev/null +++ b/utils/getContractDeployment.ts @@ -0,0 +1,15 @@ +import fs from 'fs/promises' + +async function getContractDeployment( + contractName: string, + networkName: string +) { + const Contract = await import('../deployments/' + contractName + '.json') + + return { + address: Contract[networkName].address, + args: Contract[networkName].options.args, + } +} + +export default getContractDeployment diff --git a/utils/getEnvValSafe.ts b/utils/getEnvValSafe.ts new file mode 100644 index 0000000..d6e16cd --- /dev/null +++ b/utils/getEnvValSafe.ts @@ -0,0 +1,5 @@ +export function getEnvValSafe(key: string, required = true): string { + const endpoint = process.env[key] + if (!endpoint && required) throw `Missing env var ${key}` + return endpoint || '' +} diff --git a/utils/getFacets.ts b/utils/getFacets.ts new file mode 100644 index 0000000..aef7303 --- /dev/null +++ b/utils/getFacets.ts @@ -0,0 +1,14 @@ +import fs from "fs"; +import path from "path"; + +// Load facets from the src/facets folder, return an array of facet names +function getFacets(omit: string[] = ["DiamondCutFacet", "DiamondLoupeFacet"]) { + const facets = fs + .readdirSync("./contracts/facets") + .map((file) => path.parse(file).name); + + // return array, filter out "DiamondCutFacet" and any omitted facets + return facets.filter((facet) => !omit.includes(facet)); +} + +export default getFacets; diff --git a/utils/index.ts b/utils/index.ts new file mode 100644 index 0000000..9d36311 --- /dev/null +++ b/utils/index.ts @@ -0,0 +1,37 @@ +export * from './getEnvValSafe' +// export * from "./diamond"; +export * from './saveDeployment' +export * from './wait' +export * from './getContractDeployment' +export * from './logTx' + +/* + * Starting at 15,000 VAPE per season, on Season 1, + * we will decreate the emissions by 0.41217% per season. + */ +export const calculateReward = (seasonId: number) => { + // Initial values + const initialRewards = 15000 + const reductionPercentage = 0.41217 / 100 + + let reward = initialRewards + for (let season = 2; season <= seasonId; season++) { + reward = reward - reward * reductionPercentage + } + + return reward +} + +export function getNextMonthTimestamp(): number { + const now = new Date() + const nextMonth = new Date( + Date.UTC( + now.getUTCMonth() === 11 + ? now.getUTCFullYear() + 1 + : now.getUTCFullYear(), + now.getUTCMonth() === 11 ? 0 : now.getUTCMonth() + 1, + 1 + ) + ) + return Math.floor(nextMonth.getTime() / 1000) +} diff --git a/utils/logTx.ts b/utils/logTx.ts new file mode 100644 index 0000000..a8bc8ea --- /dev/null +++ b/utils/logTx.ts @@ -0,0 +1,10 @@ +import { ContractTransactionResponse } from 'ethers' + +export async function logTx( + res: ContractTransactionResponse, + confirmations?: number +) { + console.log(`Transaction pending: ${res.hash}`) + await res.wait(confirmations ?? 1) + console.log('Done! 🎉') +} diff --git a/utils/saveDeployment.ts b/utils/saveDeployment.ts new file mode 100644 index 0000000..f667b0a --- /dev/null +++ b/utils/saveDeployment.ts @@ -0,0 +1,36 @@ +import * as fs from 'fs' +import { Artifact } from 'hardhat/types' +import { DeployOptions } from './deployContract' + +export type Deployment = { + address: string + artifact: Artifact + options: DeployOptions +} + +export const saveDeployment = ( + fileName: string, + deployment: Deployment, + networkName: string +) => { + const dirName = 'deployments' + const dirPath = `${process.cwd()}/${dirName}` + const filePath = `${dirPath}/${fileName}.json` + + if (!fs.existsSync(dirPath)) { + fs.mkdirSync(dirPath, { recursive: true }) + } + + if (!fs.existsSync(filePath)) { + fs.writeFileSync( + filePath, + JSON.stringify({ [networkName]: deployment }, null, 2) + ) + } else { + const details = JSON.parse(fs.readFileSync(filePath, { encoding: 'utf-8' })) + + details[networkName] = deployment + + fs.writeFileSync(filePath, JSON.stringify(details, null, 2)) + } +} diff --git a/utils/wait.ts b/utils/wait.ts new file mode 100644 index 0000000..9bbf033 --- /dev/null +++ b/utils/wait.ts @@ -0,0 +1,5 @@ +async function wait(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)) +} + +export default wait