diff --git a/.github/workflows/deploy-hardhat-development.yaml b/.github/workflows/deploy-hardhat-development.yaml new file mode 100644 index 000000000..a538c4a6d --- /dev/null +++ b/.github/workflows/deploy-hardhat-development.yaml @@ -0,0 +1,37 @@ +name: Deploy to hardhat Development Server + +on: + push: + branches: + - 'develop' + +jobs: + deploy-hardhat-network: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Copy files to server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + ARGS: '-rlgoDzvc -i --delete' + REMOTE_USER: ${{ secrets.REMOTE_USER }} + TARGET: '/home/penx/penx' + SOURCE: './' + + - name: Run Node.js service + uses: appleboy/ssh-action@v0.1.10 + with: + host: ${{ secrets.REMOTE_HOST }} + username: ${{ secrets.REMOTE_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + whoami + ls -al + cd /home/penx/penx/apps/protocol + npm i --no-package-lock + npm run hardhat:development diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f0d02595b..fc1a6d23e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,11 +14,11 @@ jobs: release_id: ${{ steps.create-release.outputs.result }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 - name: get version run: echo "PACKAGE_VERSION=$(node -p "require('./apps/desktop/package.json').version")" >> $GITHUB_ENV - name: create release diff --git a/.vscode/settings.json b/.vscode/settings.json index e915f110b..29daa4a18 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "search.followSymlinks": false + "search.followSymlinks": false, + "cSpell.enableFiletypes": ["solidity"] } diff --git a/apps/protocol/.gitignore b/apps/protocol/.gitignore new file mode 100644 index 000000000..626186086 --- /dev/null +++ b/apps/protocol/.gitignore @@ -0,0 +1,17 @@ +node_modules +.env +.DS_Store +.deps +.VSCodeCounter +coverage +coverage.json +typechain +typechain-types + +# Hardhat files +cache +artifacts + +types +test/generated.ts +abi diff --git a/apps/protocol/.mocharc.js b/apps/protocol/.mocharc.js new file mode 100644 index 000000000..da7803c1a --- /dev/null +++ b/apps/protocol/.mocharc.js @@ -0,0 +1,16 @@ +'use strict' +process.env.TS_NODE_FILES = true +module.exports = { + 'allow-uncaught': true, + diff: true, + extension: ['ts'], + recursive: true, + reporter: 'spec', + require: ['ts-node/register', 'hardhat/register'], // ['ts-node/register/transpile-only'], (for yarn link ) + slow: 300, + spec: 'test/**/*.test.ts', + timeout: 20000, + ui: 'bdd', + watch: false, + 'watch-files': ['src/**/*.sol', 'test/**/*.ts'], +} diff --git a/apps/protocol/.prettierrc.yml b/apps/protocol/.prettierrc.yml new file mode 100644 index 000000000..269b07ad4 --- /dev/null +++ b/apps/protocol/.prettierrc.yml @@ -0,0 +1,25 @@ +bracketSpacing: true +plugins: + - "prettier-plugin-solidity" +printWidth: 120 +proseWrap: "always" +singleQuote: true +semi: false +tabWidth: 2 +trailingComma: "all" + +overrides: + - files: "*.sol" + options: + semi: true + compiler: "0.8.17" + singleQuote: false + parser: "solidity-parse" + tabWidth: 4 + - files: "*.ts" + options: + importOrder: ["", "^[./]"] + importOrderParserPlugins: ["typescript"] + importOrderSeparation: true + importOrderSortSpecifiers: true + parser: "typescript" diff --git a/apps/protocol/README.md b/apps/protocol/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/apps/protocol/contracts/facets/DiamondCutFacet.sol b/apps/protocol/contracts/facets/DiamondCutFacet.sol new file mode 100644 index 000000000..68b5b0b94 --- /dev/null +++ b/apps/protocol/contracts/facets/DiamondCutFacet.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +/******************************************************************************/ + +import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; +import { LibDiamond } from "../storage/LibDiamond.sol"; + +// Remember to add the loupe functions from DiamondLoupeFacet to the diamond. +// The loupe functions are required by the EIP2535 Diamonds standard + +contract DiamondCutFacet is IDiamondCut { + /// @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 override { + LibDiamond.enforceIsContractOwner(); + LibDiamond.diamondCut(_diamondCut, _init, _calldata); + } +} diff --git a/apps/protocol/contracts/facets/DiamondLoupeFacet.sol b/apps/protocol/contracts/facets/DiamondLoupeFacet.sol new file mode 100644 index 000000000..61fbc7015 --- /dev/null +++ b/apps/protocol/contracts/facets/DiamondLoupeFacet.sol @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +/******************************************************************************/ + +// The functions in DiamondLoupeFacet MUST be added to a diamond. +// The EIP-2535 Diamond standard requires these functions. + +import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { LibDiamond } from "../storage/LibDiamond.sol"; +import { IDiamondLoupe } from "../interfaces/IDiamondLoupe.sol"; + +contract DiamondLoupeFacet is IDiamondLoupe, IERC165 { + // Diamond Loupe Functions + //////////////////////////////////////////////////////////////////// + /// These functions are expected to be called frequently by tools. + // + // struct Facet { + // address facetAddress; + // bytes4[] functionSelectors; + // } + /// @notice Gets all facets and their selectors. + /// @return facets_ Facet + function facets() external override view returns (Facet[] memory facets_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + uint256 selectorCount = ds.selectors.length; + // create an array set to the maximum size possible + facets_ = new Facet[](selectorCount); + // create an array for counting the number of selectors for each facet + uint16[] memory numFacetSelectors = new uint16[](selectorCount); + // total number of facets + uint256 numFacets; + // loop through function selectors + for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) { + bytes4 selector = ds.selectors[selectorIndex]; + address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress; + bool continueLoop = false; + // find the functionSelectors array for selector and add selector to it + for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { + if (facets_[facetIndex].facetAddress == facetAddress_) { + facets_[facetIndex].functionSelectors[numFacetSelectors[facetIndex]] = selector; + numFacetSelectors[facetIndex]++; + continueLoop = true; + break; + } + } + // if functionSelectors array exists for selector then continue loop + if (continueLoop) { + continueLoop = false; + continue; + } + // create a new functionSelectors array for selector + facets_[numFacets].facetAddress = facetAddress_; + facets_[numFacets].functionSelectors = new bytes4[](selectorCount); + facets_[numFacets].functionSelectors[0] = selector; + numFacetSelectors[numFacets] = 1; + numFacets++; + } + for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { + uint256 numSelectors = numFacetSelectors[facetIndex]; + bytes4[] memory selectors = facets_[facetIndex].functionSelectors; + // setting the number of selectors + assembly { + mstore(selectors, numSelectors) + } + } + // setting the number of facets + assembly { + mstore(facets_, numFacets) + } + } + + /// @notice Gets all the function selectors supported by a specific facet. + /// @param _facet The facet address. + /// @return _facetFunctionSelectors The selectors associated with a facet address. + function facetFunctionSelectors(address _facet) external override view returns (bytes4[] memory _facetFunctionSelectors) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + uint256 selectorCount = ds.selectors.length; + uint256 numSelectors; + _facetFunctionSelectors = new bytes4[](selectorCount); + // loop through function selectors + for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) { + bytes4 selector = ds.selectors[selectorIndex]; + address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress; + if (_facet == facetAddress_) { + _facetFunctionSelectors[numSelectors] = selector; + numSelectors++; + } + } + // Set the number of selectors in the array + assembly { + mstore(_facetFunctionSelectors, numSelectors) + } + } + + /// @notice Get all the facet addresses used by a diamond. + /// @return facetAddresses_ + function facetAddresses() external override view returns (address[] memory facetAddresses_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + uint256 selectorCount = ds.selectors.length; + // create an array set to the maximum size possible + facetAddresses_ = new address[](selectorCount); + uint256 numFacets; + // loop through function selectors + for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) { + bytes4 selector = ds.selectors[selectorIndex]; + address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress; + bool continueLoop = false; + // see if we have collected the address already and break out of loop if we have + for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { + if (facetAddress_ == facetAddresses_[facetIndex]) { + continueLoop = true; + break; + } + } + // continue loop if we already have the address + if (continueLoop) { + continueLoop = false; + continue; + } + // include address + facetAddresses_[numFacets] = facetAddress_; + numFacets++; + } + // Set the number of facet addresses in the array + assembly { + mstore(facetAddresses_, numFacets) + } + } + + /// @notice Gets the facet address that supports the given selector. + /// @dev If facet is not found return address(0). + /// @param _functionSelector The function selector. + /// @return facetAddress_ The facet address. + function facetAddress(bytes4 _functionSelector) external override view returns (address facetAddress_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + facetAddress_ = ds.facetAddressAndSelectorPosition[_functionSelector].facetAddress; + } + + // This implements ERC-165. + function supportsInterface(bytes4 _interfaceId) external override view returns (bool) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + return ds.supportedInterfaces[_interfaceId]; + } +} diff --git a/apps/protocol/contracts/interfaces/IDiamond.sol b/apps/protocol/contracts/interfaces/IDiamond.sol new file mode 100644 index 000000000..9662e6bb7 --- /dev/null +++ b/apps/protocol/contracts/interfaces/IDiamond.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +/******************************************************************************/ + +interface IDiamond { + enum FacetCutAction {Add, Replace, Remove} + // Add=0, Replace=1, Remove=2 + + struct FacetCut { + address facetAddress; + FacetCutAction action; + bytes4[] functionSelectors; + } + + event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); +} \ No newline at end of file diff --git a/apps/protocol/contracts/interfaces/IDiamondCut.sol b/apps/protocol/contracts/interfaces/IDiamondCut.sol new file mode 100644 index 000000000..d99de45db --- /dev/null +++ b/apps/protocol/contracts/interfaces/IDiamondCut.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +/******************************************************************************/ + +import { IDiamond } from "./IDiamond.sol"; + +interface IDiamondCut is IDiamond { + + /// @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; +} diff --git a/apps/protocol/contracts/interfaces/IDiamondLoupe.sol b/apps/protocol/contracts/interfaces/IDiamondLoupe.sol new file mode 100644 index 000000000..c3b2570fe --- /dev/null +++ b/apps/protocol/contracts/interfaces/IDiamondLoupe.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +/******************************************************************************/ + +// A loupe is a small magnifying glass used to look at diamonds. +// These functions look at diamonds +interface IDiamondLoupe { + /// These functions are expected to be called frequently + /// by tools. + + struct Facet { + address facetAddress; + bytes4[] functionSelectors; + } + + /// @notice Gets all facet addresses and their four byte function selectors. + /// @return facets_ Facet + function facets() external view returns (Facet[] memory facets_); + + /// @notice Gets all the function selectors supported by a specific facet. + /// @param _facet The facet address. + /// @return facetFunctionSelectors_ + function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_); + + /// @notice Get all the facet addresses used by a diamond. + /// @return facetAddresses_ + function facetAddresses() external view returns (address[] memory facetAddresses_); + + /// @notice Gets the facet that supports the given selector. + /// @dev If facet is not found return address(0). + /// @param _functionSelector The function selector. + /// @return facetAddress_ The facet address. + function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_); +} diff --git a/apps/protocol/contracts/mock/Multicall3.sol b/apps/protocol/contracts/mock/Multicall3.sol new file mode 100644 index 000000000..65b2885e6 --- /dev/null +++ b/apps/protocol/contracts/mock/Multicall3.sol @@ -0,0 +1,234 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +/// @title Multicall3 +/// @notice Aggregate results from multiple function calls +/// @dev Multicall & Multicall2 backwards-compatible +/// @dev Aggregate methods are marked `payable` to save 24 gas per call +/// @author Michael Elliot +/// @author Joshua Levine +/// @author Nick Johnson +/// @author Andreas Bigger +/// @author Matt Solomon +contract Multicall3 { + struct Call { + address target; + bytes callData; + } + + struct Call3 { + address target; + bool allowFailure; + bytes callData; + } + + struct Call3Value { + address target; + bool allowFailure; + uint256 value; + bytes callData; + } + + struct Result { + bool success; + bytes returnData; + } + + /// @notice Backwards-compatible call aggregation with Multicall + /// @param calls An array of Call structs + /// @return blockNumber The block number where the calls were executed + /// @return returnData An array of bytes containing the responses + function aggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData) { + blockNumber = block.number; + uint256 length = calls.length; + returnData = new bytes[](length); + Call calldata call; + for (uint256 i; i < length; ) { + bool success; + call = calls[i]; + (success, returnData[i]) = call.target.call(call.callData); + require(success, "Multicall3: call failed"); + unchecked { + ++i; + } + } + } + + /// @notice Backwards-compatible with Multicall2 + /// @notice Aggregate calls without requiring success + /// @param requireSuccess If true, require all calls to succeed + /// @param calls An array of Call structs + /// @return returnData An array of Result structs + function tryAggregate( + bool requireSuccess, + Call[] calldata calls + ) public payable returns (Result[] memory returnData) { + uint256 length = calls.length; + returnData = new Result[](length); + Call calldata call; + for (uint256 i; i < length; ) { + Result memory result = returnData[i]; + call = calls[i]; + (result.success, result.returnData) = call.target.call(call.callData); + if (requireSuccess) require(result.success, "Multicall3: call failed"); + unchecked { + ++i; + } + } + } + + /// @notice Backwards-compatible with Multicall2 + /// @notice Aggregate calls and allow failures using tryAggregate + /// @param calls An array of Call structs + /// @return blockNumber The block number where the calls were executed + /// @return blockHash The hash of the block where the calls were executed + /// @return returnData An array of Result structs + function tryBlockAndAggregate( + bool requireSuccess, + Call[] calldata calls + ) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) { + blockNumber = block.number; + blockHash = blockhash(block.number); + returnData = tryAggregate(requireSuccess, calls); + } + + /// @notice Backwards-compatible with Multicall2 + /// @notice Aggregate calls and allow failures using tryAggregate + /// @param calls An array of Call structs + /// @return blockNumber The block number where the calls were executed + /// @return blockHash The hash of the block where the calls were executed + /// @return returnData An array of Result structs + function blockAndAggregate( + Call[] calldata calls + ) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) { + (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls); + } + + /// @notice Aggregate calls, ensuring each returns success if required + /// @param calls An array of Call3 structs + /// @return returnData An array of Result structs + function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData) { + uint256 length = calls.length; + returnData = new Result[](length); + Call3 calldata calli; + for (uint256 i; i < length; ) { + Result memory result = returnData[i]; + calli = calls[i]; + (result.success, result.returnData) = calli.target.call(calli.callData); + assembly { + // Revert if the call fails and failure is not allowed + // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)` + if iszero(or(calldataload(add(calli, 0x20)), mload(result))) { + // set "Error(string)" signature: bytes32(bytes4(keccak256("Error(string)"))) + mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000) + // set data offset + mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) + // set length of revert string + mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017) + // set revert string: bytes32(abi.encodePacked("Multicall3: call failed")) + mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000) + revert(0x00, 0x64) + } + } + unchecked { + ++i; + } + } + } + + /// @notice Aggregate calls with a msg value + /// @notice Reverts if msg.value is less than the sum of the call values + /// @param calls An array of Call3Value structs + /// @return returnData An array of Result structs + function aggregate3Value(Call3Value[] calldata calls) public payable returns (Result[] memory returnData) { + uint256 valAccumulator; + uint256 length = calls.length; + returnData = new Result[](length); + Call3Value calldata calli; + for (uint256 i; i < length; ) { + Result memory result = returnData[i]; + calli = calls[i]; + uint256 val = calli.value; + // Humanity will be a Type V Kardashev Civilization before this overflows - andreas + // ~ 10^25 Wei in existence << ~ 10^76 size uint fits in a uint256 + unchecked { + valAccumulator += val; + } + (result.success, result.returnData) = calli.target.call{ value: val }(calli.callData); + assembly { + // Revert if the call fails and failure is not allowed + // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)` + if iszero(or(calldataload(add(calli, 0x20)), mload(result))) { + // set "Error(string)" signature: bytes32(bytes4(keccak256("Error(string)"))) + mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000) + // set data offset + mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) + // set length of revert string + mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017) + // set revert string: bytes32(abi.encodePacked("Multicall3: call failed")) + mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000) + revert(0x00, 0x84) + } + } + unchecked { + ++i; + } + } + // Finally, make sure the msg.value = SUM(call[0...i].value) + require(msg.value == valAccumulator, "Multicall3: value mismatch"); + } + + /// @notice Returns the block hash for the given block number + /// @param blockNumber The block number + function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) { + blockHash = blockhash(blockNumber); + } + + /// @notice Returns the block number + function getBlockNumber() public view returns (uint256 blockNumber) { + blockNumber = block.number; + } + + /// @notice Returns the block coinbase + function getCurrentBlockCoinbase() public view returns (address coinbase) { + coinbase = block.coinbase; + } + + /// @notice Returns the block prevrandao + function getCurrentBlockPrevrandao() public view returns (uint256 prevrandao) { + prevrandao = block.prevrandao; + } + + /// @notice Returns the block gas limit + function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) { + gaslimit = block.gaslimit; + } + + /// @notice Returns the block timestamp + function getCurrentBlockTimestamp() public view returns (uint256 timestamp) { + timestamp = block.timestamp; + } + + /// @notice Returns the (ETH) balance of a given address + function getEthBalance(address addr) public view returns (uint256 balance) { + balance = addr.balance; + } + + /// @notice Returns the block hash of the last block + function getLastBlockHash() public view returns (bytes32 blockHash) { + unchecked { + blockHash = blockhash(block.number - 1); + } + } + + /// @notice Gets the base fee of the given block + /// @notice Can revert if the BASEFEE opcode is not implemented by the given chain + function getBasefee() public view returns (uint256 basefee) { + basefee = block.basefee; + } + + /// @notice Returns the chain id + function getChainId() public view returns (uint256 chainid) { + chainid = block.chainid; + } +} diff --git a/apps/protocol/contracts/router/Diamond.sol b/apps/protocol/contracts/router/Diamond.sol new file mode 100644 index 000000000..1f6e6b33d --- /dev/null +++ b/apps/protocol/contracts/router/Diamond.sol @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +* +* Implementation of a diamond. +/******************************************************************************/ + +import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { LibDiamond } from "../storage/LibDiamond.sol"; +import { IDiamond } from "../interfaces/IDiamond.sol"; +import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; +import { IDiamondLoupe } from "../interfaces/IDiamondLoupe.sol"; +import "../storage/RoleAccessControl.sol"; +import "hardhat/console.sol"; + +// When no function exists for function called +error FunctionNotFound(bytes4 _functionSelector); + +contract Diamond { + constructor(address _diamondCutFacet, address _diamondLoupeFacet, address _init, address owner) payable { + RoleAccessControl.grantRole(msg.sender, RoleAccessControl.ROLE_ADMIN); + + IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](2); + bytes4[] memory functionSelectors = new bytes4[](1); + functionSelectors[0] = IDiamondCut.diamondCut.selector; + cut[0] = IDiamond.FacetCut({ + facetAddress: _diamondCutFacet, + action: IDiamond.FacetCutAction.Add, + functionSelectors: functionSelectors + }); + + bytes4[] memory loupeFunctionSelectors = new bytes4[](4); + loupeFunctionSelectors[0] = IDiamondLoupe.facets.selector; + loupeFunctionSelectors[1] = IDiamondLoupe.facetAddresses.selector; + loupeFunctionSelectors[2] = IDiamondLoupe.facetAddress.selector; + loupeFunctionSelectors[3] = IDiamondLoupe.facetFunctionSelectors.selector; + cut[1] = IDiamond.FacetCut({ + facetAddress: _diamondLoupeFacet, + action: IDiamond.FacetCutAction.Add, + functionSelectors: loupeFunctionSelectors + }); + LibDiamond.setContractOwner(owner); + LibDiamond.diamondCut(cut, _init, abi.encodeWithSignature("init()")); + } + + // Find facet for function that is called and execute the + // function if a facet is found and return any value. + fallback() external payable { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + // get facet from function selector + address facet = ds.facetAddressAndSelectorPosition[msg.sig].facetAddress; + if (facet == address(0)) { + revert FunctionNotFound(msg.sig); + } + // Execute external function from facet using delegatecall and return any value. + assembly { + // copy function selector and any arguments + calldatacopy(0, 0, calldatasize()) + // execute function call using the facet + let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0) + // get any return value + returndatacopy(0, 0, returndatasize()) + // return any return value or error back to the caller + switch result + case 0 { + revert(0, returndatasize()) + } + default { + return(0, returndatasize()) + } + } + } + + receive() external payable {} +} diff --git a/apps/protocol/contracts/router/DiamondInit.sol b/apps/protocol/contracts/router/DiamondInit.sol new file mode 100644 index 000000000..011899b8f --- /dev/null +++ b/apps/protocol/contracts/router/DiamondInit.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { LibDiamond } from "../storage/LibDiamond.sol"; +import { IDiamondLoupe } from "../interfaces/IDiamondLoupe.sol"; +import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; + +contract DiamondInit { + function init() external { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + ds.supportedInterfaces[type(IERC165).interfaceId] = true; + ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true; + ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true; + } +} diff --git a/apps/protocol/contracts/storage/LibDiamond.sol b/apps/protocol/contracts/storage/LibDiamond.sol new file mode 100644 index 000000000..a405965b8 --- /dev/null +++ b/apps/protocol/contracts/storage/LibDiamond.sol @@ -0,0 +1,204 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +/******************************************************************************\ +* Author: Nick Mudge (https://twitter.com/mudgen) +* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +/******************************************************************************/ +import { IDiamond } from "../interfaces/IDiamond.sol"; +import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; + +// Remember to add the loupe functions from DiamondLoupeFacet to the diamond. +// The loupe functions are required by the EIP2535 Diamonds standard + +error NoSelectorsGivenToAdd(); +error NotContractOwner(address _user, address _contractOwner); +error NoSelectorsProvidedForFacetForCut(address _facetAddress); +error CannotAddSelectorsToZeroAddress(bytes4[] _selectors); +error NoBytecodeAtAddress(address _contractAddress, string _message); +error IncorrectFacetCutAction(uint8 _action); +error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector); +error CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors); +error CannotReplaceImmutableFunction(bytes4 _selector); +error CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector); +error CannotReplaceFunctionThatDoesNotExists(bytes4 _selector); +error RemoveFacetAddressMustBeZeroAddress(address _facetAddress); +error CannotRemoveFunctionThatDoesNotExist(bytes4 _selector); +error CannotRemoveImmutableFunction(bytes4 _selector); +error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata); + +library LibDiamond { + bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); + + struct FacetAddressAndSelectorPosition { + address facetAddress; + uint16 selectorPosition; + } + + struct DiamondStorage { + // function selector => facet address and selector position in selectors array + mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition; + bytes4[] selectors; + mapping(bytes4 => bool) supportedInterfaces; + address contractOwner; + } + + function diamondStorage() internal pure returns (DiamondStorage storage ds) { + bytes32 position = DIAMOND_STORAGE_POSITION; + assembly { + ds.slot := position + } + } + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + function setContractOwner(address _newOwner) internal { + DiamondStorage storage ds = diamondStorage(); + address previousOwner = ds.contractOwner; + ds.contractOwner = _newOwner; + emit OwnershipTransferred(previousOwner, _newOwner); + } + + function contractOwner() internal view returns (address contractOwner_) { + contractOwner_ = diamondStorage().contractOwner; + } + + function enforceIsContractOwner() internal view { + if (msg.sender != diamondStorage().contractOwner) { + revert NotContractOwner(msg.sender, diamondStorage().contractOwner); + } + } + + event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata); + + // Internal function version of diamondCut + function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal { + for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) { + bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors; + address facetAddress = _diamondCut[facetIndex].facetAddress; + if (functionSelectors.length == 0) { + revert NoSelectorsProvidedForFacetForCut(facetAddress); + } + IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; + if (action == IDiamond.FacetCutAction.Add) { + addFunctions(facetAddress, functionSelectors); + } else if (action == IDiamond.FacetCutAction.Replace) { + replaceFunctions(facetAddress, functionSelectors); + } else if (action == IDiamond.FacetCutAction.Remove) { + removeFunctions(facetAddress, functionSelectors); + } else { + revert IncorrectFacetCutAction(uint8(action)); + } + } + emit DiamondCut(_diamondCut, _init, _calldata); + initializeDiamondCut(_init, _calldata); + } + + function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { + if (_facetAddress == address(0)) { + revert CannotAddSelectorsToZeroAddress(_functionSelectors); + } + DiamondStorage storage ds = diamondStorage(); + uint16 selectorCount = uint16(ds.selectors.length); + enforceHasContractCode(_facetAddress, "LibDiamondCut: Add facet has no code"); + for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { + bytes4 selector = _functionSelectors[selectorIndex]; + address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress; + if (oldFacetAddress != address(0)) { + revert CannotAddFunctionToDiamondThatAlreadyExists(selector); + } + ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition( + _facetAddress, + selectorCount + ); + ds.selectors.push(selector); + selectorCount++; + } + } + + function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { + DiamondStorage storage ds = diamondStorage(); + if (_facetAddress == address(0)) { + revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors); + } + enforceHasContractCode(_facetAddress, "LibDiamondCut: Replace facet has no code"); + for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { + bytes4 selector = _functionSelectors[selectorIndex]; + address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress; + // can't replace immutable functions -- functions defined directly in the diamond in this case + if (oldFacetAddress == address(this)) { + revert CannotReplaceImmutableFunction(selector); + } + if (oldFacetAddress == _facetAddress) { + revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector); + } + if (oldFacetAddress == address(0)) { + revert CannotReplaceFunctionThatDoesNotExists(selector); + } + // replace old facet address + ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress; + } + } + + function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { + DiamondStorage storage ds = diamondStorage(); + uint256 selectorCount = ds.selectors.length; + if (_facetAddress != address(0)) { + revert RemoveFacetAddressMustBeZeroAddress(_facetAddress); + } + for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { + bytes4 selector = _functionSelectors[selectorIndex]; + FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds + .facetAddressAndSelectorPosition[selector]; + if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) { + revert CannotRemoveFunctionThatDoesNotExist(selector); + } + + // can't remove immutable functions -- functions defined directly in the diamond + if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) { + revert CannotRemoveImmutableFunction(selector); + } + // replace selector with last selector + selectorCount--; + if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) { + bytes4 lastSelector = ds.selectors[selectorCount]; + ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector; + ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition + .selectorPosition; + } + // delete last selector + ds.selectors.pop(); + delete ds.facetAddressAndSelectorPosition[selector]; + } + } + + function initializeDiamondCut(address _init, bytes memory _calldata) internal { + if (_init == address(0)) { + return; + } + enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); + (bool success, bytes memory error) = _init.delegatecall(_calldata); + if (!success) { + if (error.length > 0) { + // bubble up error + /// @solidity memory-safe-assembly + assembly { + let returndata_size := mload(error) + revert(add(32, error), returndata_size) + } + } else { + revert InitializationFunctionReverted(_init, _calldata); + } + } + } + + function enforceHasContractCode(address _contract, string memory _errorMessage) internal view { + uint256 contractSize; + assembly { + contractSize := extcodesize(_contract) + } + if (contractSize == 0) { + revert NoBytecodeAtAddress(_contract, _errorMessage); + } + } +} diff --git a/apps/protocol/contracts/storage/RoleAccessControl.sol b/apps/protocol/contracts/storage/RoleAccessControl.sol new file mode 100644 index 000000000..d1b2d980d --- /dev/null +++ b/apps/protocol/contracts/storage/RoleAccessControl.sol @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; +import "../utils/Errors.sol"; + +library RoleAccessControl { + using EnumerableSet for EnumerableSet.Bytes32Set; + + bytes32 internal constant ACCESS_CONTROL_KEY = keccak256(abi.encode("link.profile.storage.AccessControl")); + + bytes32 constant ROLE_ADMIN = "ADMIN"; + bytes32 constant ROLE_CONFIG = "CONFIG"; + bytes32 constant ROLE_KEEPER = "KEEPER"; + + struct Props { + mapping(address => EnumerableSet.Bytes32Set) accountRoles; + } + + function load() public pure returns (Props storage self) { + bytes32 s = ACCESS_CONTROL_KEY; + assembly { + self.slot := s + } + } + + function checkRole(bytes32 role) internal view { + if (!hasRole(msg.sender, role)) { + revert Errors.InvalidRoleAccess(msg.sender, role); + } + } + + function hasRole(bytes32 role) internal view returns (bool) { + return hasRole(msg.sender, role); + } + + function hasRole(address account, bytes32 role) internal view returns (bool) { + Props storage self = load(); + return self.accountRoles[account].contains(role); + } + + function grantRole(address account, bytes32 role) internal { + Props storage self = load(); + self.accountRoles[account].add(role); + } + + function revokeRole(address account, bytes32 role) internal { + Props storage self = load(); + if (self.accountRoles[account].contains(role)) { + self.accountRoles[account].remove(role); + } + } + + function revokeAllRole(address account) internal { + Props storage self = load(); + delete self.accountRoles[account]; + } +} diff --git a/apps/protocol/contracts/utils/Errors.sol b/apps/protocol/contracts/utils/Errors.sol new file mode 100644 index 000000000..a98580715 --- /dev/null +++ b/apps/protocol/contracts/utils/Errors.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +library Errors { + // common + error AddressSelfNotSupported(address self); + error UnknownError(bytes msg); + error BlockNumberInvalid(); + error InvalidRoleAccess(address account, bytes32 role); + + // account + error AccountNotExist(); +} diff --git a/apps/protocol/contracts/utils/RoleKeys.sol b/apps/protocol/contracts/utils/RoleKeys.sol new file mode 100644 index 000000000..a60b9c049 --- /dev/null +++ b/apps/protocol/contracts/utils/RoleKeys.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +library RoleKeys { + bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); + + bytes32 public constant CONFIG_ROLE = keccak256("CONFIG_ROLE"); +} diff --git a/apps/protocol/deploy/deployDiamondFacets.ts b/apps/protocol/deploy/deployDiamondFacets.ts new file mode 100644 index 000000000..9cc022216 --- /dev/null +++ b/apps/protocol/deploy/deployDiamondFacets.ts @@ -0,0 +1,45 @@ +import { ethers } from 'hardhat' +import { getSelectors, FacetCutAction, getAllAlreadySelectors, getSelectorsExcludeAlready } from '../utils/diamond' +import { HardhatRuntimeEnvironment } from 'hardhat/types' + +const facetDependencies = ['Diamond', 'DiamondCutFacet', 'DiamondLoupeFacet'] + +const func = async (hre: HardhatRuntimeEnvironment) => { + if (hre.network.name != 'localhost' && hre.network.name != 'hardhat') { + return + } + const diamond = await ethers.getContract('Diamond') + const diamondAddr = await diamond.getAddress() + console.log('diamondAddr', diamondAddr) + + const alreadySelectors = await getAllAlreadySelectors(diamondAddr) + let facets = [] + let total = 0 + const diamondCutFacet = await ethers.getContractAt('DiamondCutFacet', diamondAddr) + for (var i = 3; i < facetDependencies.length; i++) { + const contract = await ethers.getContract(facetDependencies[i]) + const functionSelectors = getSelectorsExcludeAlready(contract, alreadySelectors) + if (functionSelectors.length == 0) { + continue + } + facets.push({ + facetAddress: await contract.getAddress(), + action: FacetCutAction.Add, + functionSelectors: functionSelectors, + }) + total += functionSelectors.length + if (total > 30 || (total > 0 && i == facetDependencies.length - 1)) { + const tx = await diamondCutFacet.diamondCut(facets, ethers.ZeroAddress, '0x', { gasLimit: 20000000 }) + const receipt = await tx.wait() + if (!receipt.status) { + throw Error(`Diamond init failed: ${tx.hash}`) + } + total = 0 + facets = [] + } + } +} + +func.tags = ['DiamondFacets'] +func.dependencies = facetDependencies +export default func diff --git a/apps/protocol/deploy/facets/DiamondCutFacet.ts b/apps/protocol/deploy/facets/DiamondCutFacet.ts new file mode 100644 index 000000000..25bf3302a --- /dev/null +++ b/apps/protocol/deploy/facets/DiamondCutFacet.ts @@ -0,0 +1,8 @@ +import { DeployFunctionOptions, createDeployFunction } from '../../utils/deploy' + +export const options: DeployFunctionOptions = { + contractName: 'DiamondCutFacet', + libraryNames: ['LibDiamond'], +} + +export default createDeployFunction(options) diff --git a/apps/protocol/deploy/facets/DiamondLoupeFacet.ts b/apps/protocol/deploy/facets/DiamondLoupeFacet.ts new file mode 100644 index 000000000..72d6121f3 --- /dev/null +++ b/apps/protocol/deploy/facets/DiamondLoupeFacet.ts @@ -0,0 +1,8 @@ +import { DeployFunctionOptions, createDeployFunction } from '../../utils/deploy' + +export const options: DeployFunctionOptions = { + contractName: 'DiamondLoupeFacet', + libraryNames: ['LibDiamond'], +} + +export default createDeployFunction(options) diff --git a/apps/protocol/deploy/mock/Multicall3.ts b/apps/protocol/deploy/mock/Multicall3.ts new file mode 100644 index 000000000..e54351c68 --- /dev/null +++ b/apps/protocol/deploy/mock/Multicall3.ts @@ -0,0 +1,6 @@ +import { createDeployFunction } from '../../utils/deploy' + +export default createDeployFunction({ + contractName: 'Multicall3', + id: 'Multicall3', +}) diff --git a/apps/protocol/deploy/router/Diamond.ts b/apps/protocol/deploy/router/Diamond.ts new file mode 100644 index 000000000..0e3068b94 --- /dev/null +++ b/apps/protocol/deploy/router/Diamond.ts @@ -0,0 +1,18 @@ +import { DeployFunctionOptions, createDeployFunction } from '../../utils/deploy' + +export const options: DeployFunctionOptions = { + contractName: 'Diamond', + dependencyNames: ['DiamondCutFacet', 'DiamondLoupeFacet', 'DiamondInit'], + libraryNames: ['LibDiamond'], + getDeployArgs: async ({ dependencyContracts }) => { + const { deployer } = await getNamedAccounts() + return [ + dependencyContracts.DiamondCutFacet.address, + dependencyContracts.DiamondLoupeFacet.address, + dependencyContracts.DiamondInit.address, + deployer, + ] + }, +} + +export default createDeployFunction(options) diff --git a/apps/protocol/deploy/router/DiamondInit.ts b/apps/protocol/deploy/router/DiamondInit.ts new file mode 100644 index 000000000..1dcf028a4 --- /dev/null +++ b/apps/protocol/deploy/router/DiamondInit.ts @@ -0,0 +1,8 @@ +import { DeployFunctionOptions, createDeployFunction } from '../../utils/deploy' + +export const options: DeployFunctionOptions = { + contractName: 'DiamondInit', + libraryNames: ['LibDiamond'], +} + +export default createDeployFunction(options) diff --git a/apps/protocol/deploy/storage/LibDiamond.ts b/apps/protocol/deploy/storage/LibDiamond.ts new file mode 100644 index 000000000..9a01328ef --- /dev/null +++ b/apps/protocol/deploy/storage/LibDiamond.ts @@ -0,0 +1,7 @@ +import { DeployFunctionOptions, createDeployFunction } from '../../utils/deploy' + +export const options: DeployFunctionOptions = { + contractName: 'LibDiamond', +} + +export default createDeployFunction(options) diff --git a/apps/protocol/deployments/localhost/.chainId b/apps/protocol/deployments/localhost/.chainId new file mode 100644 index 000000000..027791f42 --- /dev/null +++ b/apps/protocol/deployments/localhost/.chainId @@ -0,0 +1 @@ +31337 \ No newline at end of file diff --git a/apps/protocol/deployments/localhost/Diamond.json b/apps/protocol/deployments/localhost/Diamond.json new file mode 100644 index 000000000..9671ff559 --- /dev/null +++ b/apps/protocol/deployments/localhost/Diamond.json @@ -0,0 +1,272 @@ +{ + "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_diamondCutFacet", + "type": "address" + }, + { + "internalType": "address", + "name": "_diamondLoupeFacet", + "type": "address" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotAddFunctionToDiamondThatAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4[]", + "name": "_selectors", + "type": "bytes4[]" + } + ], + "name": "CannotAddSelectorsToZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotRemoveFunctionThatDoesNotExist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotRemoveImmutableFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotReplaceFunctionThatDoesNotExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4[]", + "name": "_selectors", + "type": "bytes4[]" + } + ], + "name": "CannotReplaceFunctionsFromFacetWithZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotReplaceImmutableFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "FunctionNotFound", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "_action", + "type": "uint8" + } + ], + "name": "IncorrectFacetCutAction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_initializationContractAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "InitializationFunctionReverted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_contractAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "_message", + "type": "string" + } + ], + "name": "NoBytecodeAtAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facetAddress", + "type": "address" + } + ], + "name": "NoSelectorsProvidedForFacetForCut", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facetAddress", + "type": "address" + } + ], + "name": "RemoveFacetAddressMustBeZeroAddress", + "type": "error" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x779e381ba29e8513688b77f18912164aa34acf7cd0bfb78e9516b92f71eb8072", + "receipt": { + "to": null, + "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "contractAddress": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + "transactionIndex": 0, + "gasUsed": "1568920", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000001000000000800000000000000000000020000000000000100000800000000000000000000000000000000400020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000002020000000000000000020000000000000000000000000000000000000000001000000000100000000000000", + "blockHash": "0x5025bb13d89518a4a25abf24afff30d7b4cf6a0d6a2e275f49b9731ea0942159", + "transactionHash": "0x779e381ba29e8513688b77f18912164aa34acf7cd0bfb78e9516b92f71eb8072", + "logs": [ + { + "transactionIndex": 0, + "blockNumber": 5, + "transactionHash": "0x779e381ba29e8513688b77f18912164aa34acf7cd0bfb78e9516b92f71eb8072", + "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x5025bb13d89518a4a25abf24afff30d7b4cf6a0d6a2e275f49b9731ea0942159" + }, + { + "transactionIndex": 0, + "blockNumber": 5, + "transactionHash": "0x779e381ba29e8513688b77f18912164aa34acf7cd0bfb78e9516b92f71eb8072", + "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + "topics": ["0x8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000cf7ed3acca5a467e9e704c703e8d87f634fb0fc900000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000e7f1725e7734ce288f8367e1bb143e90bb3f05120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000011f931c1c000000000000000000000000000000000000000000000000000000000000000000000000000000009fe46736679d2d9a65f0992f2272de9f3c7fa6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000047a0ed6270000000000000000000000000000000000000000000000000000000052ef6b2c00000000000000000000000000000000000000000000000000000000cdffacc600000000000000000000000000000000000000000000000000000000adfca15e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004e1c7392a00000000000000000000000000000000000000000000000000000000", + "logIndex": 1, + "blockHash": "0x5025bb13d89518a4a25abf24afff30d7b4cf6a0d6a2e275f49b9731ea0942159" + } + ], + "blockNumber": 5, + "cumulativeGasUsed": "1568920", + "status": 1, + "byzantium": true + }, + "args": [ + "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", + "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", + "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + ], + "numDeployments": 1, + "solcInputHash": "a5a4b4fb9b01e798eddcfdb1da63d0bc", + "metadata": "{\"compiler\":{\"version\":\"0.8.18+commit.87f61d96\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_diamondCutFacet\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_diamondLoupeFacet\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_init\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotAddFunctionToDiamondThatAlreadyExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"_selectors\",\"type\":\"bytes4[]\"}],\"name\":\"CannotAddSelectorsToZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotRemoveFunctionThatDoesNotExist\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotRemoveImmutableFunction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotReplaceFunctionThatDoesNotExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"_selectors\",\"type\":\"bytes4[]\"}],\"name\":\"CannotReplaceFunctionsFromFacetWithZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotReplaceImmutableFunction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_functionSelector\",\"type\":\"bytes4\"}],\"name\":\"FunctionNotFound\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"_action\",\"type\":\"uint8\"}],\"name\":\"IncorrectFacetCutAction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_initializationContractAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_calldata\",\"type\":\"bytes\"}],\"name\":\"InitializationFunctionReverted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_contractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_message\",\"type\":\"string\"}],\"name\":\"NoBytecodeAtAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_facetAddress\",\"type\":\"address\"}],\"name\":\"NoSelectorsProvidedForFacetForCut\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_facetAddress\",\"type\":\"address\"}],\"name\":\"RemoveFacetAddressMustBeZeroAddress\",\"type\":\"error\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/router/Diamond.sol\":\"Diamond\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":4294967295},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\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\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```solidity\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x9f4357008a8f7d8c8bf5d48902e789637538d8c016be5766610901b4bba81514\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamond {\\n enum FacetCutAction {Add, Replace, Remove}\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\\n}\",\"keccak256\":\"0x37be579b243559c0c16a8de037d2c428e8fafdfdd9cde69fa165a07f5adfda2c\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport { IDiamond } from \\\"./IDiamond.sol\\\";\\n\\ninterface IDiamondCut is IDiamond { \\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external; \\n}\\n\",\"keccak256\":\"0x9ecd4a637b7cb44c26a4ab7760766defce42a6dc36a355b92dfeef9ce4391fee\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondLoupe.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\n// A loupe is a small magnifying glass used to look at diamonds.\\n// These functions look at diamonds\\ninterface IDiamondLoupe {\\n /// These functions are expected to be called frequently\\n /// by tools.\\n\\n struct Facet {\\n address facetAddress;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Gets all facet addresses and their four byte function selectors.\\n /// @return facets_ Facet\\n function facets() external view returns (Facet[] memory facets_);\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return facetFunctionSelectors_\\n function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses() external view returns (address[] memory facetAddresses_);\\n\\n /// @notice Gets the facet that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);\\n}\\n\",\"keccak256\":\"0x10884024af2c0f7deca0fac4ddf84e76da5dba35b6e02fabeac8ea54c1a5c6f7\",\"license\":\"MIT\"},\"contracts/router/Diamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n*\\n* Implementation of a diamond.\\n/******************************************************************************/\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\nimport { LibDiamond } from \\\"../storage/LibDiamond.sol\\\";\\nimport { IDiamond } from \\\"../interfaces/IDiamond.sol\\\";\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\nimport { IDiamondLoupe } from \\\"../interfaces/IDiamondLoupe.sol\\\";\\nimport \\\"../storage/RoleAccessControl.sol\\\";\\nimport \\\"hardhat/console.sol\\\";\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\ncontract Diamond {\\n constructor(address _diamondCutFacet, address _diamondLoupeFacet, address _init, address owner) payable {\\n RoleAccessControl.grantRole(msg.sender, RoleAccessControl.ROLE_ADMIN);\\n\\n IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](2);\\n bytes4[] memory functionSelectors = new bytes4[](1);\\n functionSelectors[0] = IDiamondCut.diamondCut.selector;\\n cut[0] = IDiamond.FacetCut({\\n facetAddress: _diamondCutFacet,\\n action: IDiamond.FacetCutAction.Add,\\n functionSelectors: functionSelectors\\n });\\n\\n bytes4[] memory loupeFunctionSelectors = new bytes4[](4);\\n loupeFunctionSelectors[0] = IDiamondLoupe.facets.selector;\\n loupeFunctionSelectors[1] = IDiamondLoupe.facetAddresses.selector;\\n loupeFunctionSelectors[2] = IDiamondLoupe.facetAddress.selector;\\n loupeFunctionSelectors[3] = IDiamondLoupe.facetFunctionSelectors.selector;\\n cut[1] = IDiamond.FacetCut({\\n facetAddress: _diamondLoupeFacet,\\n action: IDiamond.FacetCutAction.Add,\\n functionSelectors: loupeFunctionSelectors\\n });\\n LibDiamond.setContractOwner(owner);\\n LibDiamond.diamondCut(cut, _init, abi.encodeWithSignature(\\\"init()\\\"));\\n }\\n\\n // Find facet for function that is called and execute the\\n // function if a facet is found and return any value.\\n fallback() external payable {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n // get facet from function selector\\n address facet = ds.facetAddressAndSelectorPosition[msg.sig].facetAddress;\\n if (facet == address(0)) {\\n revert FunctionNotFound(msg.sig);\\n }\\n // Execute external function from facet using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the facet\\n let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n receive() external payable {}\\n}\\n\",\"keccak256\":\"0xda084cd9697461c31e9f63fc15d1799fc167ee857397915f4a14a1d32bc13bf7\",\"license\":\"MIT\"},\"contracts/storage/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport { IDiamond } from \\\"../interfaces/IDiamond.sol\\\";\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\\n// The loupe functions are required by the EIP2535 Diamonds standard\\n\\nerror NoSelectorsGivenToAdd();\\nerror NotContractOwner(address _user, address _contractOwner);\\nerror NoSelectorsProvidedForFacetForCut(address _facetAddress);\\nerror CannotAddSelectorsToZeroAddress(bytes4[] _selectors);\\nerror NoBytecodeAtAddress(address _contractAddress, string _message);\\nerror IncorrectFacetCutAction(uint8 _action);\\nerror CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);\\nerror CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);\\nerror CannotReplaceImmutableFunction(bytes4 _selector);\\nerror CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);\\nerror CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);\\nerror RemoveFacetAddressMustBeZeroAddress(address _facetAddress);\\nerror CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);\\nerror CannotRemoveImmutableFunction(bytes4 _selector);\\nerror InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct FacetAddressAndSelectorPosition {\\n address facetAddress;\\n uint16 selectorPosition;\\n }\\n\\n struct DiamondStorage {\\n // function selector => facet address and selector position in selectors array\\n mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;\\n bytes4[] selectors;\\n mapping(bytes4 => bool) supportedInterfaces;\\n address contractOwner;\\n }\\n\\n function diamondStorage() internal pure returns (DiamondStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n if (msg.sender != diamondStorage().contractOwner) {\\n revert NotContractOwner(msg.sender, diamondStorage().contractOwner);\\n }\\n }\\n\\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);\\n\\n // Internal function version of diamondCut\\n function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {\\n for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\\n bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors;\\n address facetAddress = _diamondCut[facetIndex].facetAddress;\\n if (functionSelectors.length == 0) {\\n revert NoSelectorsProvidedForFacetForCut(facetAddress);\\n }\\n IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;\\n if (action == IDiamond.FacetCutAction.Add) {\\n addFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Replace) {\\n replaceFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Remove) {\\n removeFunctions(facetAddress, functionSelectors);\\n } else {\\n revert IncorrectFacetCutAction(uint8(action));\\n }\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n if (_facetAddress == address(0)) {\\n revert CannotAddSelectorsToZeroAddress(_functionSelectors);\\n }\\n DiamondStorage storage ds = diamondStorage();\\n uint16 selectorCount = uint16(ds.selectors.length);\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Add facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n if (oldFacetAddress != address(0)) {\\n revert CannotAddFunctionToDiamondThatAlreadyExists(selector);\\n }\\n ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(\\n _facetAddress,\\n selectorCount\\n );\\n ds.selectors.push(selector);\\n selectorCount++;\\n }\\n }\\n\\n function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n if (_facetAddress == address(0)) {\\n revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);\\n }\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Replace facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n // can't replace immutable functions -- functions defined directly in the diamond in this case\\n if (oldFacetAddress == address(this)) {\\n revert CannotReplaceImmutableFunction(selector);\\n }\\n if (oldFacetAddress == _facetAddress) {\\n revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);\\n }\\n if (oldFacetAddress == address(0)) {\\n revert CannotReplaceFunctionThatDoesNotExists(selector);\\n }\\n // replace old facet address\\n ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress;\\n }\\n }\\n\\n function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n if (_facetAddress != address(0)) {\\n revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);\\n }\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds\\n .facetAddressAndSelectorPosition[selector];\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {\\n revert CannotRemoveFunctionThatDoesNotExist(selector);\\n }\\n\\n // can't remove immutable functions -- functions defined directly in the diamond\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {\\n revert CannotRemoveImmutableFunction(selector);\\n }\\n // replace selector with last selector\\n selectorCount--;\\n if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {\\n bytes4 lastSelector = ds.selectors[selectorCount];\\n ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;\\n ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition\\n .selectorPosition;\\n }\\n // delete last selector\\n ds.selectors.pop();\\n delete ds.facetAddressAndSelectorPosition[selector];\\n }\\n }\\n\\n function initializeDiamondCut(address _init, bytes memory _calldata) internal {\\n if (_init == address(0)) {\\n return;\\n }\\n enforceHasContractCode(_init, \\\"LibDiamondCut: _init address has no code\\\");\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up error\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(error)\\n revert(add(32, error), returndata_size)\\n }\\n } else {\\n revert InitializationFunctionReverted(_init, _calldata);\\n }\\n }\\n }\\n\\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n if (contractSize == 0) {\\n revert NoBytecodeAtAddress(_contract, _errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4a4aa3ee1fa8366a19930b6b98cce435187052d142312a03db92ef9d27fb1b69\",\"license\":\"MIT\"},\"contracts/storage/RoleAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"../utils/Errors.sol\\\";\\n\\nlibrary RoleAccessControl {\\n using EnumerableSet for EnumerableSet.Bytes32Set;\\n\\n bytes32 internal constant ACCESS_CONTROL_KEY = keccak256(abi.encode(\\\"link.profile.storage.AccessControl\\\"));\\n\\n bytes32 constant ROLE_ADMIN = \\\"ADMIN\\\";\\n bytes32 constant ROLE_CONFIG = \\\"CONFIG\\\";\\n bytes32 constant ROLE_KEEPER = \\\"KEEPER\\\";\\n\\n struct Props {\\n mapping(address => EnumerableSet.Bytes32Set) accountRoles;\\n }\\n\\n function load() public pure returns (Props storage self) {\\n bytes32 s = ACCESS_CONTROL_KEY;\\n assembly {\\n self.slot := s\\n }\\n }\\n\\n function checkRole(bytes32 role) internal view {\\n if (!hasRole(msg.sender, role)) {\\n revert Errors.InvalidRoleAccess(msg.sender, role);\\n }\\n }\\n\\n function hasRole(bytes32 role) internal view returns (bool) {\\n return hasRole(msg.sender, role);\\n }\\n\\n function hasRole(address account, bytes32 role) internal view returns (bool) {\\n Props storage self = load();\\n return self.accountRoles[account].contains(role);\\n }\\n\\n function grantRole(address account, bytes32 role) internal {\\n Props storage self = load();\\n self.accountRoles[account].add(role);\\n }\\n\\n function revokeRole(address account, bytes32 role) internal {\\n Props storage self = load();\\n if (self.accountRoles[account].contains(role)) {\\n self.accountRoles[account].remove(role);\\n }\\n }\\n\\n function revokeAllRole(address account) internal {\\n Props storage self = load();\\n delete self.accountRoles[account];\\n }\\n}\\n\",\"keccak256\":\"0xc92236139ef9749a2e95153a0a93b5cdb910bacfa1fc69c061cd168c78f97056\",\"license\":\"MIT\"},\"contracts/utils/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\nlibrary Errors {\\n // common\\n error AddressSelfNotSupported(address self);\\n error UnknownError(bytes msg);\\n error BlockNumberInvalid();\\n error InvalidRoleAccess(address account, bytes32 role);\\n\\n // account\\n error AccountNotExist();\\n}\\n\",\"keccak256\":\"0x8f7d5347b130786f945ac2d54ea8a08cd2fa34947dc7d1a4216ffb86749ed6bf\",\"license\":\"MIT\"},\"hardhat/console.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.22 <0.9.0;\\n\\nlibrary console {\\n address constant CONSOLE_ADDRESS =\\n 0x000000000000000000636F6e736F6c652e6c6f67;\\n\\n function _sendLogPayloadImplementation(bytes memory payload) internal view {\\n address consoleAddress = CONSOLE_ADDRESS;\\n /// @solidity memory-safe-assembly\\n assembly {\\n pop(\\n staticcall(\\n gas(),\\n consoleAddress,\\n add(payload, 32),\\n mload(payload),\\n 0,\\n 0\\n )\\n )\\n }\\n }\\n\\n function _castToPure(\\n function(bytes memory) internal view fnIn\\n ) internal pure returns (function(bytes memory) pure fnOut) {\\n assembly {\\n fnOut := fnIn\\n }\\n }\\n\\n function _sendLogPayload(bytes memory payload) internal pure {\\n _castToPure(_sendLogPayloadImplementation)(payload);\\n }\\n\\n function log() internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log()\\\"));\\n }\\n function logInt(int256 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(int256)\\\", p0));\\n }\\n\\n function logUint(uint256 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256)\\\", p0));\\n }\\n\\n function logString(string memory p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string)\\\", p0));\\n }\\n\\n function logBool(bool p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool)\\\", p0));\\n }\\n\\n function logAddress(address p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address)\\\", p0));\\n }\\n\\n function logBytes(bytes memory p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes)\\\", p0));\\n }\\n\\n function logBytes1(bytes1 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes1)\\\", p0));\\n }\\n\\n function logBytes2(bytes2 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes2)\\\", p0));\\n }\\n\\n function logBytes3(bytes3 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes3)\\\", p0));\\n }\\n\\n function logBytes4(bytes4 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes4)\\\", p0));\\n }\\n\\n function logBytes5(bytes5 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes5)\\\", p0));\\n }\\n\\n function logBytes6(bytes6 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes6)\\\", p0));\\n }\\n\\n function logBytes7(bytes7 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes7)\\\", p0));\\n }\\n\\n function logBytes8(bytes8 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes8)\\\", p0));\\n }\\n\\n function logBytes9(bytes9 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes9)\\\", p0));\\n }\\n\\n function logBytes10(bytes10 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes10)\\\", p0));\\n }\\n\\n function logBytes11(bytes11 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes11)\\\", p0));\\n }\\n\\n function logBytes12(bytes12 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes12)\\\", p0));\\n }\\n\\n function logBytes13(bytes13 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes13)\\\", p0));\\n }\\n\\n function logBytes14(bytes14 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes14)\\\", p0));\\n }\\n\\n function logBytes15(bytes15 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes15)\\\", p0));\\n }\\n\\n function logBytes16(bytes16 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes16)\\\", p0));\\n }\\n\\n function logBytes17(bytes17 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes17)\\\", p0));\\n }\\n\\n function logBytes18(bytes18 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes18)\\\", p0));\\n }\\n\\n function logBytes19(bytes19 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes19)\\\", p0));\\n }\\n\\n function logBytes20(bytes20 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes20)\\\", p0));\\n }\\n\\n function logBytes21(bytes21 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes21)\\\", p0));\\n }\\n\\n function logBytes22(bytes22 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes22)\\\", p0));\\n }\\n\\n function logBytes23(bytes23 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes23)\\\", p0));\\n }\\n\\n function logBytes24(bytes24 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes24)\\\", p0));\\n }\\n\\n function logBytes25(bytes25 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes25)\\\", p0));\\n }\\n\\n function logBytes26(bytes26 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes26)\\\", p0));\\n }\\n\\n function logBytes27(bytes27 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes27)\\\", p0));\\n }\\n\\n function logBytes28(bytes28 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes28)\\\", p0));\\n }\\n\\n function logBytes29(bytes29 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes29)\\\", p0));\\n }\\n\\n function logBytes30(bytes30 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes30)\\\", p0));\\n }\\n\\n function logBytes31(bytes31 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes31)\\\", p0));\\n }\\n\\n function logBytes32(bytes32 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bytes32)\\\", p0));\\n }\\n\\n function log(uint256 p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256)\\\", p0));\\n }\\n\\n function log(string memory p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string)\\\", p0));\\n }\\n\\n function log(bool p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool)\\\", p0));\\n }\\n\\n function log(address p0) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address)\\\", p0));\\n }\\n\\n function log(uint256 p0, uint256 p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256)\\\", p0, p1));\\n }\\n\\n function log(uint256 p0, string memory p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string)\\\", p0, p1));\\n }\\n\\n function log(uint256 p0, bool p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool)\\\", p0, p1));\\n }\\n\\n function log(uint256 p0, address p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address)\\\", p0, p1));\\n }\\n\\n function log(string memory p0, uint256 p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256)\\\", p0, p1));\\n }\\n\\n function log(string memory p0, string memory p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string)\\\", p0, p1));\\n }\\n\\n function log(string memory p0, bool p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool)\\\", p0, p1));\\n }\\n\\n function log(string memory p0, address p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address)\\\", p0, p1));\\n }\\n\\n function log(bool p0, uint256 p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256)\\\", p0, p1));\\n }\\n\\n function log(bool p0, string memory p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string)\\\", p0, p1));\\n }\\n\\n function log(bool p0, bool p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool)\\\", p0, p1));\\n }\\n\\n function log(bool p0, address p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address)\\\", p0, p1));\\n }\\n\\n function log(address p0, uint256 p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256)\\\", p0, p1));\\n }\\n\\n function log(address p0, string memory p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string)\\\", p0, p1));\\n }\\n\\n function log(address p0, bool p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool)\\\", p0, p1));\\n }\\n\\n function log(address p0, address p1) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address)\\\", p0, p1));\\n }\\n\\n function log(uint256 p0, uint256 p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, uint256 p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,string)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, uint256 p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, uint256 p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,address)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, string memory p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, string memory p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,string)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, string memory p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, string memory p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,address)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, bool p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, bool p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,string)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, bool p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, bool p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,address)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, address p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, address p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,string)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, address p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, address p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,address)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, uint256 p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, uint256 p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,string)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, uint256 p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, uint256 p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,address)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, string memory p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, string memory p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,string)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, string memory p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, string memory p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,address)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, bool p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, bool p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,string)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, bool p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, bool p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,address)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, address p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, address p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,string)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, address p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(string memory p0, address p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,address)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, uint256 p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, uint256 p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,string)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, uint256 p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, uint256 p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,address)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, string memory p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, string memory p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,string)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, string memory p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, string memory p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,address)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, bool p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, bool p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,string)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, bool p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, bool p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,address)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, address p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, address p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,string)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, address p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(bool p0, address p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,address)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, uint256 p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, uint256 p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,string)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, uint256 p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, uint256 p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,address)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, string memory p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, string memory p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,string)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, string memory p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, string memory p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,address)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, bool p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, bool p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,string)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, bool p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, bool p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,address)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, address p1, uint256 p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,uint256)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, address p1, string memory p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,string)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, address p1, bool p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,bool)\\\", p0, p1, p2));\\n }\\n\\n function log(address p0, address p1, address p2) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,address)\\\", p0, p1, p2));\\n }\\n\\n function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, uint256 p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,uint256,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, string memory p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,string,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, bool p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,bool,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(uint256 p0, address p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(uint256,address,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, uint256 p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,uint256,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, string memory p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,string,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, bool p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,bool,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(string memory p0, address p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(string,address,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, uint256 p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,uint256,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, string memory p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,string,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, bool p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,bool,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(bool p0, address p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(bool,address,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, uint256 p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,uint256,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, string memory p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,string,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, bool p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,bool,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, uint256 p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,uint256,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, uint256 p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,uint256,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, uint256 p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,uint256,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, uint256 p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,uint256,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, string memory p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,string,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, string memory p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,string,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, string memory p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,string,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, string memory p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,string,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, bool p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,bool,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, bool p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,bool,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, bool p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,bool,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, bool p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,bool,address)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, address p2, uint256 p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,address,uint256)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, address p2, string memory p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,address,string)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, address p2, bool p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,address,bool)\\\", p0, p1, p2, p3));\\n }\\n\\n function log(address p0, address p1, address p2, address p3) internal pure {\\n _sendLogPayload(abi.encodeWithSignature(\\\"log(address,address,address,address)\\\", p0, p1, p2, p3));\\n }\\n\\n}\\n\",\"keccak256\":\"0x7434453e6d3b7d0e5d0eb7846ffdbc27f0ccf3b163591263739b628074dc103a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040526040516200259c3803806200259c833981016040819052620000269162000d89565b62000045336420a226a4a760d91b620002e360201b620000ff1760201c565b60408051600280825260608201909252600091816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816200005d5750506040805160018082528183019092529192506000919060208083019080368337019050509050631f931c1c60e01b81600081518110620000d057620000d062000de6565b6001600160e01b031990921660209283029190910182015260408051606081019091526001600160a01b038816815290810160008152602001828152508260008151811062000123576200012362000de6565b602090810291909101015260408051600480825260a08201909252600091816020016020820280368337019050509050637a0ed62760e01b8160008151811062000171576200017162000de6565b6001600160e01b03199092166020928302919091019091015280516314bbdacb60e21b9082906001908110620001ab57620001ab62000de6565b6001600160e01b03199092166020928302919091019091015280516366ffd66360e11b9082906002908110620001e557620001e562000de6565b6001600160e01b03199092166020928302919091019091015280516356fe50af60e11b90829060039081106200021f576200021f62000de6565b6001600160e01b031990921660209283029190910182015260408051606081019091526001600160a01b038816815290810160008152602001828152508360018151811062000272576200027262000de6565b602002602001018190525062000293846200032860201b620001411760201c565b604080516004815260248101909152602080820180516001600160e01b03166370e39c9560e11b179052620002d6918591889190620001fb620003ac821b17901c565b505050505050506200108f565b6000620002ef6200058d565b6001600160a01b0384166000908152602082815260409091209192506200032291908490620003ea620005fb821b17901c565b50505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f80546001600160a01b031981166001600160a01b03848116918217909355604051600080516020620024e8833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60005b83518110156200053e576000848281518110620003d057620003d062000de6565b60200260200101516040015190506000858381518110620003f557620003f562000de6565b60200260200101516000015190508151600003620004365760405163e767f91f60e01b81526001600160a01b03821660048201526024015b60405180910390fd5b60008684815181106200044d576200044d62000de6565b60200260200101516020015190506000600281111562000471576200047162000dfc565b81600281111562000486576200048662000dfc565b036200049e5762000498828462000612565b62000525565b6001816002811115620004b557620004b562000dfc565b03620004c757620004988284620007d8565b6002816002811115620004de57620004de62000dfc565b03620004f05762000498828462000979565b80600281111562000505576200050562000dfc565b604051633ff4d20f60e11b815260ff90911660048201526024016200042d565b5050508080620005359062000e28565b915050620003af565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673838383604051620005749392919062000e98565b60405180910390a162000588828262000c1d565b505050565b600080604051602001620005dd9060208082526022908201527f6c696e6b2e70726f66696c652e73746f726167652e416363657373436f6e74726040820152611bdb60f21b606082015260800190565b60408051601f19818403018152919052805160209091012092915050565b600062000609838362000cef565b90505b92915050565b6001600160a01b0382166200063e57806040516302b8da0760e21b81526004016200042d919062000f9f565b600080516020620025548339815191525460408051606081019091526024808252600080516020620024e88339815191529291620006889186919062002508602083013962000d41565b60005b8351811015620007d1576000848281518110620006ac57620006ac62000de6565b6020908102919091018101516001600160e01b031981166000908152918690526040909120549091506001600160a01b031680156200070b5760405163ebbf5d0760e01b81526001600160e01b0319831660048201526024016200042d565b6040805180820182526001600160a01b03808a16825261ffff80881660208085019182526001600160e01b0319881660009081528b8252958620945185549251909316600160a01b026001600160b01b0319909216929093169190911717909155600180880180549182018155835291206008820401805460e085901c60046007909416939093026101000a92830263ffffffff909302191691909117905583620007b68162000fef565b94505050508080620007c89062000e28565b9150506200068b565b5050505050565b600080516020620024e88339815191526001600160a01b03831662000814578160405163cd98a96f60e01b81526004016200042d919062000f9f565b6200083983604051806060016040528060288152602001620025746028913962000d41565b60005b8251811015620003225760008382815181106200085d576200085d62000de6565b6020908102919091018101516001600160e01b031981166000908152918590526040909120549091506001600160a01b0316308103620008bd57604051632901806d60e11b81526001600160e01b0319831660048201526024016200042d565b856001600160a01b0316816001600160a01b031603620008fd57604051631ac6ce8d60e11b81526001600160e01b0319831660048201526024016200042d565b6001600160a01b0381166200093257604051637479f93960e01b81526001600160e01b0319831660048201526024016200042d565b506001600160e01b031916600090815260208390526040902080546001600160a01b0319166001600160a01b03861617905580620009708162000e28565b9150506200083c565b6000805160206200255483398151915254600080516020620024e8833981519152906001600160a01b03841615620009d05760405163d091bc8160e01b81526001600160a01b03851660048201526024016200042d565b60005b8351811015620007d1576000848281518110620009f457620009f462000de6565b6020908102919091018101516001600160e01b0319811660009081528683526040908190208151808301909252546001600160a01b038116808352600160a01b90910461ffff16938201939093529092509062000a7157604051637a08a22d60e01b81526001600160e01b0319831660048201526024016200042d565b8051306001600160a01b039091160362000aab57604051630df5fd6160e31b81526001600160e01b0319831660048201526024016200042d565b8362000ab78162001013565b94505083816020015161ffff161462000b9c57600085600101858154811062000ae45762000ae462000de6565b90600052602060002090600891828204019190066004029054906101000a900460e01b90508086600101836020015161ffff168154811062000b2a5762000b2a62000de6565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c92909202939093179055838201516001600160e01b03199390931681529087905260409020805461ffff60a01b1916600160a01b61ffff909316929092029190911790555b8460010180548062000bb25762000bb26200102d565b60008281526020808220600860001990940193840401805463ffffffff600460078716026101000a0219169055919092556001600160e01b0319909316815291859052506040902080546001600160b01b03191690558062000c148162000e28565b915050620009d3565b6001600160a01b03821662000c30575050565b62000c55826040518060600160405280602881526020016200252c6028913962000d41565b600080836001600160a01b03168360405162000c72919062001043565b600060405180830381855af49150503d806000811462000caf576040519150601f19603f3d011682016040523d82523d6000602084013e62000cb4565b606091505b509150915081620003225780511562000cd05780518082602001fd5b838360405163192105d760e01b81526004016200042d92919062001061565b600081815260018301602052604081205462000d38575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200060c565b5060006200060c565b813b60008190036200058857828260405163919834b960e01b81526004016200042d92919062001061565b80516001600160a01b038116811462000d8457600080fd5b919050565b6000806000806080858703121562000da057600080fd5b62000dab8562000d6c565b935062000dbb6020860162000d6c565b925062000dcb6040860162000d6c565b915062000ddb6060860162000d6c565b905092959194509250565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000e3d5762000e3d62000e12565b5060010190565b60005b8381101562000e6157818101518382015260200162000e47565b50506000910152565b6000815180845262000e8481602086016020860162000e44565b601f01601f19169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562000f6d57898403607f19018652815180516001600160a01b0316855283810151898601906003811062000f0957634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b8083101562000f575783516001600160e01b031916825292860192600192909201919086019062000f2b565b5097850197955050509082019060010162000ec1565b50506001600160a01b038a1690880152868103604088015262000f91818962000e6a565b9a9950505050505050505050565b6020808252825182820181905260009190848201906040850190845b8181101562000fe35783516001600160e01b0319168352928401929184019160010162000fbb565b50909695505050505050565b600061ffff80831681810362001009576200100962000e12565b6001019392505050565b60008162001025576200102562000e12565b506000190190565b634e487b7160e01b600052603160045260246000fd5b600082516200105781846020870162000e44565b9190910192915050565b6001600160a01b0383168152604060208201819052600090620010879083018462000e6a565b949350505050565b611449806200109f6000396000f3fe60806040523661000b57005b60007fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600080357fffffffff000000000000000000000000000000000000000000000000000000001681526020829052604090205490915073ffffffffffffffffffffffffffffffffffffffff16806100db576040517f5416eb980000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000006000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156100fa573d6000f35b3d6000fd5b60006101096103ff565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208290526040902090915061013b90836103ea565b50505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff8481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60005b835181101561039f57600084828151811061021b5761021b610fc6565b6020026020010151604001519050600085838151811061023d5761023d610fc6565b6020026020010151600001519050815160000361029e576040517fe767f91f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016100d2565b60008684815181106102b2576102b2610fc6565b6020026020010151602001519050600060028111156102d3576102d3610ff5565b8160028111156102e5576102e5610ff5565b036102f9576102f482846104a5565b610389565b600181600281111561030d5761030d610ff5565b0361031c576102f48284610746565b600281600281111561033057610330610ff5565b0361033f576102f48284610a27565b80600281111561035157610351610ff5565b6040517f7fe9a41e00000000000000000000000000000000000000000000000000000000815260ff90911660048201526024016100d2565b505050808061039790611053565b9150506101fe565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103d3939291906110f9565b60405180910390a16103e58282610e3d565b505050565b60006103f68383610f36565b90505b92915050565b6000806040516020016104699060208082526022908201527f6c696e6b2e70726f66696c652e73746f726167652e416363657373436f6e747260408201527f6f6c000000000000000000000000000000000000000000000000000000000000606082015260800190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012092915050565b73ffffffffffffffffffffffffffffffffffffffff82166104f457806040517f0ae3681c0000000000000000000000000000000000000000000000000000000081526004016100d29190611261565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d54604080516060810190915260248082527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c929161055d918691906113a06020830139610f85565b60005b835181101561073f57600084828151811061057d5761057d610fc6565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff168015610630576040517febbf5d070000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b60408051808201825273ffffffffffffffffffffffffffffffffffffffff808a16825261ffff80881660208085019182527fffffffff00000000000000000000000000000000000000000000000000000000881660009081528b825295862094518554925190931674010000000000000000000000000000000000000000027fffffffffffffffffffff00000000000000000000000000000000000000000000909216929093169190911717909155600180880180549182018155835291206008820401805460e085901c60046007909416939093026101000a92830263ffffffff909302191691909117905583610727816112c7565b9450505050808061073790611053565b915050610560565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff83166107b657816040517fcd98a96f0000000000000000000000000000000000000000000000000000000081526004016100d29190611261565b6107d8836040518060600160405280602881526020016113ec60289139610f85565b60005b825181101561013b5760008382815181106107f8576107f8610fc6565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff163081036108ac576040517f520300da0000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b8573ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610935576040517f358d9d1a0000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b73ffffffffffffffffffffffffffffffffffffffff81166109a6576040517f7479f9390000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b507fffffffff0000000000000000000000000000000000000000000000000000000016600090815260208390526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905580610a1f81611053565b9150506107db565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d547fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff841615610ad1576040517fd091bc8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851660048201526024016100d2565b60005b835181101561073f576000848281518110610af157610af1610fc6565b6020908102919091018101517fffffffff000000000000000000000000000000000000000000000000000000008116600090815286835260409081902081518083019092525473ffffffffffffffffffffffffffffffffffffffff81168083527401000000000000000000000000000000000000000090910461ffff169382019390935290925090610bd3576040517f7a08a22d0000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b80513073ffffffffffffffffffffffffffffffffffffffff90911603610c49576040517f6fafeb080000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b83610c53816112e8565b94505083816020015161ffff1614610d74576000856001018581548110610c7c57610c7c610fc6565b90600052602060002090600891828204019190066004029054906101000a900460e01b90508086600101836020015161ffff1681548110610cbf57610cbf610fc6565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c92909202939093179055838201517fffffffff00000000000000000000000000000000000000000000000000000000939093168152908790526040902080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff909316929092029190911790555b84600101805480610d8757610d8761131d565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff00000000000000000000000000000000000000000000000000000000909316815291859052506040902080547fffffffffffffffffffff0000000000000000000000000000000000000000000016905580610e3581611053565b915050610ad4565b73ffffffffffffffffffffffffffffffffffffffff8216610e5c575050565b610e7e826040518060600160405280602881526020016113c460289139610f85565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610ea6919061134c565b600060405180830381855af49150503d8060008114610ee1576040519150601f19603f3d011682016040523d82523d6000602084013e610ee6565b606091505b50915091508161013b57805115610f005780518082602001fd5b83836040517f192105d70000000000000000000000000000000000000000000000000000000081526004016100d2929190611368565b6000818152600183016020526040812054610f7d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556103f9565b5060006103f9565b813b60008190036103e55782826040517f919834b90000000000000000000000000000000000000000000000000000000081526004016100d2929190611368565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361108457611084611024565b5060010190565b60005b838110156110a657818101518382015260200161108e565b50506000910152565b600081518084526110c781602086016020860161108b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b84811015611224577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff825116865284820151600381106111ab577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b8083101561120f5783517fffffffff000000000000000000000000000000000000000000000000000000001682529286019260019290920191908601906111cd565b50978501979550505090820190600101611122565b505073ffffffffffffffffffffffffffffffffffffffff8a1690880152868103604088015261125381896110af565b9a9950505050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156112bb5783517fffffffff00000000000000000000000000000000000000000000000000000000168352928401929184019160010161127d565b50909695505050505050565b600061ffff8083168181036112de576112de611024565b6001019392505050565b6000816112f7576112f7611024565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000825161135e81846020870161108b565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff8316815260406020820152600061139760408301846110af565b94935050505056fe4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a264697066735822122092cee972226d3b0a381c171ea675741dc941705cdfa18b961cef9da488b6a35664736f6c63430008120033c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f6465c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d4c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465", + "deployedBytecode": "0x60806040523661000b57005b60007fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600080357fffffffff000000000000000000000000000000000000000000000000000000001681526020829052604090205490915073ffffffffffffffffffffffffffffffffffffffff16806100db576040517f5416eb980000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000006000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156100fa573d6000f35b3d6000fd5b60006101096103ff565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208290526040902090915061013b90836103ea565b50505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff8481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60005b835181101561039f57600084828151811061021b5761021b610fc6565b6020026020010151604001519050600085838151811061023d5761023d610fc6565b6020026020010151600001519050815160000361029e576040517fe767f91f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016100d2565b60008684815181106102b2576102b2610fc6565b6020026020010151602001519050600060028111156102d3576102d3610ff5565b8160028111156102e5576102e5610ff5565b036102f9576102f482846104a5565b610389565b600181600281111561030d5761030d610ff5565b0361031c576102f48284610746565b600281600281111561033057610330610ff5565b0361033f576102f48284610a27565b80600281111561035157610351610ff5565b6040517f7fe9a41e00000000000000000000000000000000000000000000000000000000815260ff90911660048201526024016100d2565b505050808061039790611053565b9150506101fe565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103d3939291906110f9565b60405180910390a16103e58282610e3d565b505050565b60006103f68383610f36565b90505b92915050565b6000806040516020016104699060208082526022908201527f6c696e6b2e70726f66696c652e73746f726167652e416363657373436f6e747260408201527f6f6c000000000000000000000000000000000000000000000000000000000000606082015260800190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012092915050565b73ffffffffffffffffffffffffffffffffffffffff82166104f457806040517f0ae3681c0000000000000000000000000000000000000000000000000000000081526004016100d29190611261565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d54604080516060810190915260248082527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c929161055d918691906113a06020830139610f85565b60005b835181101561073f57600084828151811061057d5761057d610fc6565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff168015610630576040517febbf5d070000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b60408051808201825273ffffffffffffffffffffffffffffffffffffffff808a16825261ffff80881660208085019182527fffffffff00000000000000000000000000000000000000000000000000000000881660009081528b825295862094518554925190931674010000000000000000000000000000000000000000027fffffffffffffffffffff00000000000000000000000000000000000000000000909216929093169190911717909155600180880180549182018155835291206008820401805460e085901c60046007909416939093026101000a92830263ffffffff909302191691909117905583610727816112c7565b9450505050808061073790611053565b915050610560565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff83166107b657816040517fcd98a96f0000000000000000000000000000000000000000000000000000000081526004016100d29190611261565b6107d8836040518060600160405280602881526020016113ec60289139610f85565b60005b825181101561013b5760008382815181106107f8576107f8610fc6565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff163081036108ac576040517f520300da0000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b8573ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610935576040517f358d9d1a0000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b73ffffffffffffffffffffffffffffffffffffffff81166109a6576040517f7479f9390000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b507fffffffff0000000000000000000000000000000000000000000000000000000016600090815260208390526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617905580610a1f81611053565b9150506107db565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d547fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff841615610ad1576040517fd091bc8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851660048201526024016100d2565b60005b835181101561073f576000848281518110610af157610af1610fc6565b6020908102919091018101517fffffffff000000000000000000000000000000000000000000000000000000008116600090815286835260409081902081518083019092525473ffffffffffffffffffffffffffffffffffffffff81168083527401000000000000000000000000000000000000000090910461ffff169382019390935290925090610bd3576040517f7a08a22d0000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b80513073ffffffffffffffffffffffffffffffffffffffff90911603610c49576040517f6fafeb080000000000000000000000000000000000000000000000000000000081527fffffffff00000000000000000000000000000000000000000000000000000000831660048201526024016100d2565b83610c53816112e8565b94505083816020015161ffff1614610d74576000856001018581548110610c7c57610c7c610fc6565b90600052602060002090600891828204019190066004029054906101000a900460e01b90508086600101836020015161ffff1681548110610cbf57610cbf610fc6565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c92909202939093179055838201517fffffffff00000000000000000000000000000000000000000000000000000000939093168152908790526040902080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff909316929092029190911790555b84600101805480610d8757610d8761131d565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff00000000000000000000000000000000000000000000000000000000909316815291859052506040902080547fffffffffffffffffffff0000000000000000000000000000000000000000000016905580610e3581611053565b915050610ad4565b73ffffffffffffffffffffffffffffffffffffffff8216610e5c575050565b610e7e826040518060600160405280602881526020016113c460289139610f85565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610ea6919061134c565b600060405180830381855af49150503d8060008114610ee1576040519150601f19603f3d011682016040523d82523d6000602084013e610ee6565b606091505b50915091508161013b57805115610f005780518082602001fd5b83836040517f192105d70000000000000000000000000000000000000000000000000000000081526004016100d2929190611368565b6000818152600183016020526040812054610f7d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556103f9565b5060006103f9565b813b60008190036103e55782826040517f919834b90000000000000000000000000000000000000000000000000000000081526004016100d2929190611368565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361108457611084611024565b5060010190565b60005b838110156110a657818101518382015260200161108e565b50506000910152565b600081518084526110c781602086016020860161108b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b84811015611224577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff825116865284820151600381106111ab577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b8083101561120f5783517fffffffff000000000000000000000000000000000000000000000000000000001682529286019260019290920191908601906111cd565b50978501979550505090820190600101611122565b505073ffffffffffffffffffffffffffffffffffffffff8a1690880152868103604088015261125381896110af565b9a9950505050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156112bb5783517fffffffff00000000000000000000000000000000000000000000000000000000168352928401929184019160010161127d565b50909695505050505050565b600061ffff8083168181036112de576112de611024565b6001019392505050565b6000816112f7576112f7611024565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000825161135e81846020870161108b565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff8316815260406020820152600061139760408301846110af565b94935050505056fe4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a264697066735822122092cee972226d3b0a381c171ea675741dc941705cdfa18b961cef9da488b6a35664736f6c63430008120033", + "libraries": { + "LibDiamond": "0x5FbDB2315678afecb367f032d93F642f64180aa3" + }, + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/apps/protocol/deployments/localhost/DiamondCutFacet.json b/apps/protocol/deployments/localhost/DiamondCutFacet.json new file mode 100644 index 000000000..e9773f7ed --- /dev/null +++ b/apps/protocol/deployments/localhost/DiamondCutFacet.json @@ -0,0 +1,307 @@ +{ + "address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotAddFunctionToDiamondThatAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4[]", + "name": "_selectors", + "type": "bytes4[]" + } + ], + "name": "CannotAddSelectorsToZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotRemoveFunctionThatDoesNotExist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotRemoveImmutableFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotReplaceFunctionThatDoesNotExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4[]", + "name": "_selectors", + "type": "bytes4[]" + } + ], + "name": "CannotReplaceFunctionsFromFacetWithZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "CannotReplaceImmutableFunction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "_action", + "type": "uint8" + } + ], + "name": "IncorrectFacetCutAction", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_initializationContractAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "InitializationFunctionReverted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_contractAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "_message", + "type": "string" + } + ], + "name": "NoBytecodeAtAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facetAddress", + "type": "address" + } + ], + "name": "NoSelectorsProvidedForFacetForCut", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "internalType": "address", + "name": "_contractOwner", + "type": "address" + } + ], + "name": "NotContractOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facetAddress", + "type": "address" + } + ], + "name": "RemoveFacetAddressMustBeZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamond.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamond.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" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamond.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamond.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x7f79f133481d7e99f7ef43ad18f843f8579494db6bf94fe89c4d4d3ee6ed51e7", + "receipt": { + "to": null, + "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "contractAddress": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", + "transactionIndex": 0, + "gasUsed": "1251265", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xbbed83290b65cfabf7925ff4272ba6a3315614e12b70263f2a648d11b1574ee0", + "transactionHash": "0x7f79f133481d7e99f7ef43ad18f843f8579494db6bf94fe89c4d4d3ee6ed51e7", + "logs": [], + "blockNumber": 2, + "cumulativeGasUsed": "1251265", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "51a2a82961a43c75be79c94bce10e613", + "metadata": "{\"compiler\":{\"version\":\"0.8.18+commit.87f61d96\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotAddFunctionToDiamondThatAlreadyExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"_selectors\",\"type\":\"bytes4[]\"}],\"name\":\"CannotAddSelectorsToZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotRemoveFunctionThatDoesNotExist\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotRemoveImmutableFunction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotReplaceFunctionThatDoesNotExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"_selectors\",\"type\":\"bytes4[]\"}],\"name\":\"CannotReplaceFunctionsFromFacetWithZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_selector\",\"type\":\"bytes4\"}],\"name\":\"CannotReplaceImmutableFunction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"_action\",\"type\":\"uint8\"}],\"name\":\"IncorrectFacetCutAction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_initializationContractAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_calldata\",\"type\":\"bytes\"}],\"name\":\"InitializationFunctionReverted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_contractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_message\",\"type\":\"string\"}],\"name\":\"NoBytecodeAtAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_facetAddress\",\"type\":\"address\"}],\"name\":\"NoSelectorsProvidedForFacetForCut\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_contractOwner\",\"type\":\"address\"}],\"name\":\"NotContractOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_facetAddress\",\"type\":\"address\"}],\"name\":\"RemoveFacetAddressMustBeZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"enum IDiamond.FacetCutAction\",\"name\":\"action\",\"type\":\"uint8\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"indexed\":false,\"internalType\":\"struct IDiamond.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\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"enum IDiamond.FacetCutAction\",\"name\":\"action\",\"type\":\"uint8\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"internalType\":\"struct IDiamond.FacetCut[]\",\"name\":\"_diamondCut\",\"type\":\"tuple[]\"},{\"internalType\":\"address\",\"name\":\"_init\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_calldata\",\"type\":\"bytes\"}],\"name\":\"diamondCut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"diamondCut((address,uint8,bytes4[])[],address,bytes)\":{\"params\":{\"_calldata\":\"A function call, including function selector and arguments _calldata is executed with delegatecall on _init\",\"_diamondCut\":\"Contains the facet addresses and function selectors\",\"_init\":\"The address of the contract or facet to execute _calldata\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"diamondCut((address,uint8,bytes4[])[],address,bytes)\":{\"notice\":\"Add/replace/remove any number of functions and optionally execute a function with delegatecall\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/DiamondCutFacet.sol\":\"DiamondCutFacet\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":4294967295},\"remappings\":[]},\"sources\":{\"contracts/facets/DiamondCutFacet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\nimport { LibDiamond } from \\\"../storage/LibDiamond.sol\\\";\\n\\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\\n// The loupe functions are required by the EIP2535 Diamonds standard\\n\\ncontract DiamondCutFacet is IDiamondCut {\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external override {\\n LibDiamond.enforceIsContractOwner();\\n LibDiamond.diamondCut(_diamondCut, _init, _calldata);\\n }\\n}\\n\",\"keccak256\":\"0x8f5f6478dffc9b2ba28a888f461986f8f98ade59f0e80e46e465508a2be0a41e\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamond {\\n enum FacetCutAction {Add, Replace, Remove}\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\\n}\",\"keccak256\":\"0x37be579b243559c0c16a8de037d2c428e8fafdfdd9cde69fa165a07f5adfda2c\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport { IDiamond } from \\\"./IDiamond.sol\\\";\\n\\ninterface IDiamondCut is IDiamond { \\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external; \\n}\\n\",\"keccak256\":\"0x9ecd4a637b7cb44c26a4ab7760766defce42a6dc36a355b92dfeef9ce4391fee\",\"license\":\"MIT\"},\"contracts/storage/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport { IDiamond } from \\\"../interfaces/IDiamond.sol\\\";\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\\n// The loupe functions are required by the EIP2535 Diamonds standard\\n\\nerror NoSelectorsGivenToAdd();\\nerror NotContractOwner(address _user, address _contractOwner);\\nerror NoSelectorsProvidedForFacetForCut(address _facetAddress);\\nerror CannotAddSelectorsToZeroAddress(bytes4[] _selectors);\\nerror NoBytecodeAtAddress(address _contractAddress, string _message);\\nerror IncorrectFacetCutAction(uint8 _action);\\nerror CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);\\nerror CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);\\nerror CannotReplaceImmutableFunction(bytes4 _selector);\\nerror CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);\\nerror CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);\\nerror RemoveFacetAddressMustBeZeroAddress(address _facetAddress);\\nerror CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);\\nerror CannotRemoveImmutableFunction(bytes4 _selector);\\nerror InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct FacetAddressAndSelectorPosition {\\n address facetAddress;\\n uint16 selectorPosition;\\n }\\n\\n struct DiamondStorage {\\n // function selector => facet address and selector position in selectors array\\n mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;\\n bytes4[] selectors;\\n mapping(bytes4 => bool) supportedInterfaces;\\n address contractOwner;\\n }\\n\\n function diamondStorage() internal pure returns (DiamondStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n if (msg.sender != diamondStorage().contractOwner) {\\n revert NotContractOwner(msg.sender, diamondStorage().contractOwner);\\n }\\n }\\n\\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);\\n\\n // Internal function version of diamondCut\\n function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {\\n for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\\n bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors;\\n address facetAddress = _diamondCut[facetIndex].facetAddress;\\n if (functionSelectors.length == 0) {\\n revert NoSelectorsProvidedForFacetForCut(facetAddress);\\n }\\n IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;\\n if (action == IDiamond.FacetCutAction.Add) {\\n addFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Replace) {\\n replaceFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Remove) {\\n removeFunctions(facetAddress, functionSelectors);\\n } else {\\n revert IncorrectFacetCutAction(uint8(action));\\n }\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n if (_facetAddress == address(0)) {\\n revert CannotAddSelectorsToZeroAddress(_functionSelectors);\\n }\\n DiamondStorage storage ds = diamondStorage();\\n uint16 selectorCount = uint16(ds.selectors.length);\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Add facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n if (oldFacetAddress != address(0)) {\\n revert CannotAddFunctionToDiamondThatAlreadyExists(selector);\\n }\\n ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(\\n _facetAddress,\\n selectorCount\\n );\\n ds.selectors.push(selector);\\n selectorCount++;\\n }\\n }\\n\\n function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n if (_facetAddress == address(0)) {\\n revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);\\n }\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Replace facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n // can't replace immutable functions -- functions defined directly in the diamond in this case\\n if (oldFacetAddress == address(this)) {\\n revert CannotReplaceImmutableFunction(selector);\\n }\\n if (oldFacetAddress == _facetAddress) {\\n revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);\\n }\\n if (oldFacetAddress == address(0)) {\\n revert CannotReplaceFunctionThatDoesNotExists(selector);\\n }\\n // replace old facet address\\n ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress;\\n }\\n }\\n\\n function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n if (_facetAddress != address(0)) {\\n revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);\\n }\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds\\n .facetAddressAndSelectorPosition[selector];\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {\\n revert CannotRemoveFunctionThatDoesNotExist(selector);\\n }\\n\\n // can't remove immutable functions -- functions defined directly in the diamond\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {\\n revert CannotRemoveImmutableFunction(selector);\\n }\\n // replace selector with last selector\\n selectorCount--;\\n if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {\\n bytes4 lastSelector = ds.selectors[selectorCount];\\n ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;\\n ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition\\n .selectorPosition;\\n }\\n // delete last selector\\n ds.selectors.pop();\\n delete ds.facetAddressAndSelectorPosition[selector];\\n }\\n }\\n\\n function initializeDiamondCut(address _init, bytes memory _calldata) internal {\\n if (_init == address(0)) {\\n return;\\n }\\n enforceHasContractCode(_init, \\\"LibDiamondCut: _init address has no code\\\");\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up error\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(error)\\n revert(add(32, error), returndata_size)\\n }\\n } else {\\n revert InitializationFunctionReverted(_init, _calldata);\\n }\\n }\\n }\\n\\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n if (contractSize == 0) {\\n revert NoBytecodeAtAddress(_contract, _errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4a4aa3ee1fa8366a19930b6b98cce435187052d142312a03db92ef9d27fb1b69\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506115e7806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004610e8b565b610045565b005b61004d61009e565b61009761005a8587611008565b8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061015992505050565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6003015473ffffffffffffffffffffffffffffffffffffffff163314610157577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f546040517fff4127cb00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff90911660248201526044015b60405180910390fd5b565b60005b83518110156102fd57600084828151811061017957610179611164565b6020026020010151604001519050600085838151811061019b5761019b611164565b602002602001015160000151905081516000036101fc576040517fe767f91f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161014e565b600086848151811061021057610210611164565b60200260200101516020015190506000600281111561023157610231611193565b81600281111561024357610243611193565b03610257576102528284610348565b6102e7565b600181600281111561026b5761026b611193565b0361027a5761025282846105e2565b600281600281111561028e5761028e611193565b0361029d5761025282846108c9565b8060028111156102af576102af611193565b6040517f7fe9a41e00000000000000000000000000000000000000000000000000000000815260ff909116600482015260240161014e565b50505080806102f5906111f1565b91505061015c565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb67383838360405161033193929190611297565b60405180910390a16103438282610cdf565b505050565b73ffffffffffffffffffffffffffffffffffffffff821661039757806040517f0ae3681c00000000000000000000000000000000000000000000000000000000815260040161014e91906113ff565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d54604080516060810190915260248082527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c92916104009186919061153e6020830139610dd8565b60005b835181101561009757600084828151811061042057610420611164565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff1680156104d3576040517febbf5d070000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b60408051808201825273ffffffffffffffffffffffffffffffffffffffff808a16825261ffff80881660208085019182527fffffffff00000000000000000000000000000000000000000000000000000000881660009081528b825295862094518554925190931674010000000000000000000000000000000000000000027fffffffffffffffffffff00000000000000000000000000000000000000000000909216929093169190911717909155600180880180549182018155835291206008820401805460e085901c60046007909416939093026101000a92830263ffffffff9093021916919091179055836105ca81611465565b945050505080806105da906111f1565b915050610403565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff831661065257816040517fcd98a96f00000000000000000000000000000000000000000000000000000000815260040161014e91906113ff565b6106748360405180606001604052806028815260200161158a60289139610dd8565b60005b82518110156108c357600083828151811061069457610694611164565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff16308103610748576040517f520300da0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b8573ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036107d1576040517f358d9d1a0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b73ffffffffffffffffffffffffffffffffffffffff8116610842576040517f7479f9390000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b507fffffffff0000000000000000000000000000000000000000000000000000000016600090815260208390526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616179055806108bb816111f1565b915050610677565b50505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d547fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff841615610973576040517fd091bc8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240161014e565b60005b835181101561009757600084828151811061099357610993611164565b6020908102919091018101517fffffffff000000000000000000000000000000000000000000000000000000008116600090815286835260409081902081518083019092525473ffffffffffffffffffffffffffffffffffffffff81168083527401000000000000000000000000000000000000000090910461ffff169382019390935290925090610a75576040517f7a08a22d0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b80513073ffffffffffffffffffffffffffffffffffffffff90911603610aeb576040517f6fafeb080000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b83610af581611486565b94505083816020015161ffff1614610c16576000856001018581548110610b1e57610b1e611164565b90600052602060002090600891828204019190066004029054906101000a900460e01b90508086600101836020015161ffff1681548110610b6157610b61611164565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c92909202939093179055838201517fffffffff00000000000000000000000000000000000000000000000000000000939093168152908790526040902080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff909316929092029190911790555b84600101805480610c2957610c296114bb565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff00000000000000000000000000000000000000000000000000000000909316815291859052506040902080547fffffffffffffffffffff0000000000000000000000000000000000000000000016905580610cd7816111f1565b915050610976565b73ffffffffffffffffffffffffffffffffffffffff8216610cfe575050565b610d208260405180606001604052806028815260200161156260289139610dd8565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610d4891906114ea565b600060405180830381855af49150503d8060008114610d83576040519150601f19603f3d011682016040523d82523d6000602084013e610d88565b606091505b5091509150816108c357805115610da25780518082602001fd5b83836040517f192105d700000000000000000000000000000000000000000000000000000000815260040161014e929190611506565b813b60008190036103435782826040517f919834b900000000000000000000000000000000000000000000000000000000815260040161014e929190611506565b803573ffffffffffffffffffffffffffffffffffffffff81168114610e3d57600080fd5b919050565b60008083601f840112610e5457600080fd5b50813567ffffffffffffffff811115610e6c57600080fd5b602083019150836020828501011115610e8457600080fd5b9250929050565b600080600080600060608688031215610ea357600080fd5b853567ffffffffffffffff80821115610ebb57600080fd5b818801915088601f830112610ecf57600080fd5b813581811115610ede57600080fd5b8960208260051b8501011115610ef357600080fd5b60208301975080965050610f0960208901610e19565b94506040880135915080821115610f1f57600080fd5b50610f2c88828901610e42565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715610f8f57610f8f610f3d565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610fdc57610fdc610f3d565b604052919050565b600067ffffffffffffffff821115610ffe57610ffe610f3d565b5060051b60200190565b600061101b61101684610fe4565b610f95565b83815260208082019190600586811b86013681111561103957600080fd5b865b8181101561115757803567ffffffffffffffff8082111561105c5760008081fd5b818a019150606082360312156110725760008081fd5b61107a610f6c565b61108383610e19565b815286830135600381106110975760008081fd5b81880152604083810135838111156110af5760008081fd5b939093019236601f8501126110c657600092508283fd5b833592506110d661101684610fe4565b83815292871b840188019288810190368511156110f35760008081fd5b948901945b848610156111405785357fffffffff00000000000000000000000000000000000000000000000000000000811681146111315760008081fd5b825294890194908901906110f8565b91830191909152508852505094830194830161103b565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611222576112226111c2565b5060010190565b60005b8381101561124457818101518382015260200161122c565b50506000910152565b60008151808452611265816020860160208601611229565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b848110156113c2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff82511686528482015160038110611349577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156113ad5783517fffffffff0000000000000000000000000000000000000000000000000000000016825292860192600192909201919086019061136b565b509785019795505050908201906001016112c0565b505073ffffffffffffffffffffffffffffffffffffffff8a169088015286810360408801526113f1818961124d565b9a9950505050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156114595783517fffffffff00000000000000000000000000000000000000000000000000000000168352928401929184019160010161141b565b50909695505050505050565b600061ffff80831681810361147c5761147c6111c2565b6001019392505050565b600081611495576114956111c2565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600082516114fc818460208701611229565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201526000611535604083018461124d565b94935050505056fe4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a264697066735822122086e26860270729f8c4b9d1aff273451c567d23dee3a14f07146f9d75bb2d5dd764736f6c63430008120033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004610e8b565b610045565b005b61004d61009e565b61009761005a8587611008565b8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061015992505050565b5050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6003015473ffffffffffffffffffffffffffffffffffffffff163314610157577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f546040517fff4127cb00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff90911660248201526044015b60405180910390fd5b565b60005b83518110156102fd57600084828151811061017957610179611164565b6020026020010151604001519050600085838151811061019b5761019b611164565b602002602001015160000151905081516000036101fc576040517fe767f91f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161014e565b600086848151811061021057610210611164565b60200260200101516020015190506000600281111561023157610231611193565b81600281111561024357610243611193565b03610257576102528284610348565b6102e7565b600181600281111561026b5761026b611193565b0361027a5761025282846105e2565b600281600281111561028e5761028e611193565b0361029d5761025282846108c9565b8060028111156102af576102af611193565b6040517f7fe9a41e00000000000000000000000000000000000000000000000000000000815260ff909116600482015260240161014e565b50505080806102f5906111f1565b91505061015c565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb67383838360405161033193929190611297565b60405180910390a16103438282610cdf565b505050565b73ffffffffffffffffffffffffffffffffffffffff821661039757806040517f0ae3681c00000000000000000000000000000000000000000000000000000000815260040161014e91906113ff565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d54604080516060810190915260248082527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c92916104009186919061153e6020830139610dd8565b60005b835181101561009757600084828151811061042057610420611164565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529186905260409091205490915073ffffffffffffffffffffffffffffffffffffffff1680156104d3576040517febbf5d070000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b60408051808201825273ffffffffffffffffffffffffffffffffffffffff808a16825261ffff80881660208085019182527fffffffff00000000000000000000000000000000000000000000000000000000881660009081528b825295862094518554925190931674010000000000000000000000000000000000000000027fffffffffffffffffffff00000000000000000000000000000000000000000000909216929093169190911717909155600180880180549182018155835291206008820401805460e085901c60046007909416939093026101000a92830263ffffffff9093021916919091179055836105ca81611465565b945050505080806105da906111f1565b915050610403565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c73ffffffffffffffffffffffffffffffffffffffff831661065257816040517fcd98a96f00000000000000000000000000000000000000000000000000000000815260040161014e91906113ff565b6106748360405180606001604052806028815260200161158a60289139610dd8565b60005b82518110156108c357600083828151811061069457610694611164565b6020908102919091018101517fffffffff00000000000000000000000000000000000000000000000000000000811660009081529185905260409091205490915073ffffffffffffffffffffffffffffffffffffffff16308103610748576040517f520300da0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b8573ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036107d1576040517f358d9d1a0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b73ffffffffffffffffffffffffffffffffffffffff8116610842576040517f7479f9390000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b507fffffffff0000000000000000000000000000000000000000000000000000000016600090815260208390526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616179055806108bb816111f1565b915050610677565b50505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d547fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9073ffffffffffffffffffffffffffffffffffffffff841615610973576040517fd091bc8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240161014e565b60005b835181101561009757600084828151811061099357610993611164565b6020908102919091018101517fffffffff000000000000000000000000000000000000000000000000000000008116600090815286835260409081902081518083019092525473ffffffffffffffffffffffffffffffffffffffff81168083527401000000000000000000000000000000000000000090910461ffff169382019390935290925090610a75576040517f7a08a22d0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b80513073ffffffffffffffffffffffffffffffffffffffff90911603610aeb576040517f6fafeb080000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008316600482015260240161014e565b83610af581611486565b94505083816020015161ffff1614610c16576000856001018581548110610b1e57610b1e611164565b90600052602060002090600891828204019190066004029054906101000a900460e01b90508086600101836020015161ffff1681548110610b6157610b61611164565b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c92909202939093179055838201517fffffffff00000000000000000000000000000000000000000000000000000000939093168152908790526040902080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff909316929092029190911790555b84600101805480610c2957610c296114bb565b6000828152602080822060087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90940193840401805463ffffffff600460078716026101000a0219169055919092557fffffffff00000000000000000000000000000000000000000000000000000000909316815291859052506040902080547fffffffffffffffffffff0000000000000000000000000000000000000000000016905580610cd7816111f1565b915050610976565b73ffffffffffffffffffffffffffffffffffffffff8216610cfe575050565b610d208260405180606001604052806028815260200161156260289139610dd8565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610d4891906114ea565b600060405180830381855af49150503d8060008114610d83576040519150601f19603f3d011682016040523d82523d6000602084013e610d88565b606091505b5091509150816108c357805115610da25780518082602001fd5b83836040517f192105d700000000000000000000000000000000000000000000000000000000815260040161014e929190611506565b813b60008190036103435782826040517f919834b900000000000000000000000000000000000000000000000000000000815260040161014e929190611506565b803573ffffffffffffffffffffffffffffffffffffffff81168114610e3d57600080fd5b919050565b60008083601f840112610e5457600080fd5b50813567ffffffffffffffff811115610e6c57600080fd5b602083019150836020828501011115610e8457600080fd5b9250929050565b600080600080600060608688031215610ea357600080fd5b853567ffffffffffffffff80821115610ebb57600080fd5b818801915088601f830112610ecf57600080fd5b813581811115610ede57600080fd5b8960208260051b8501011115610ef357600080fd5b60208301975080965050610f0960208901610e19565b94506040880135915080821115610f1f57600080fd5b50610f2c88828901610e42565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715610f8f57610f8f610f3d565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610fdc57610fdc610f3d565b604052919050565b600067ffffffffffffffff821115610ffe57610ffe610f3d565b5060051b60200190565b600061101b61101684610fe4565b610f95565b83815260208082019190600586811b86013681111561103957600080fd5b865b8181101561115757803567ffffffffffffffff8082111561105c5760008081fd5b818a019150606082360312156110725760008081fd5b61107a610f6c565b61108383610e19565b815286830135600381106110975760008081fd5b81880152604083810135838111156110af5760008081fd5b939093019236601f8501126110c657600092508283fd5b833592506110d661101684610fe4565b83815292871b840188019288810190368511156110f35760008081fd5b948901945b848610156111405785357fffffffff00000000000000000000000000000000000000000000000000000000811681146111315760008081fd5b825294890194908901906110f8565b91830191909152508852505094830194830161103b565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611222576112226111c2565b5060010190565b60005b8381101561124457818101518382015260200161122c565b50506000910152565b60008151808452611265816020860160208601611229565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b848110156113c2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808a8503018652815188850173ffffffffffffffffffffffffffffffffffffffff82511686528482015160038110611349577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156113ad5783517fffffffff0000000000000000000000000000000000000000000000000000000016825292860192600192909201919086019061136b565b509785019795505050908201906001016112c0565b505073ffffffffffffffffffffffffffffffffffffffff8a169088015286810360408801526113f1818961124d565b9a9950505050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156114595783517fffffffff00000000000000000000000000000000000000000000000000000000168352928401929184019160010161141b565b50909695505050505050565b600061ffff80831681810361147c5761147c6111c2565b6001019392505050565b600081611495576114956111c2565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600082516114fc818460208701611229565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201526000611535604083018461124d565b94935050505056fe4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a264697066735822122086e26860270729f8c4b9d1aff273451c567d23dee3a14f07146f9d75bb2d5dd764736f6c63430008120033", + "libraries": { + "LibDiamond": "0x5FbDB2315678afecb367f032d93F642f64180aa3" + }, + "devdoc": { + "kind": "dev", + "methods": { + "diamondCut((address,uint8,bytes4[])[],address,bytes)": { + "params": { + "_calldata": "A function call, including function selector and arguments _calldata is executed with delegatecall on _init", + "_diamondCut": "Contains the facet addresses and function selectors", + "_init": "The address of the contract or facet to execute _calldata" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "diamondCut((address,uint8,bytes4[])[],address,bytes)": { + "notice": "Add/replace/remove any number of functions and optionally execute a function with delegatecall" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/apps/protocol/deployments/localhost/DiamondInit.json b/apps/protocol/deployments/localhost/DiamondInit.json new file mode 100644 index 000000000..317f2f739 --- /dev/null +++ b/apps/protocol/deployments/localhost/DiamondInit.json @@ -0,0 +1,51 @@ +{ + "address": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + "abi": [ + { + "inputs": [], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x8bec9208c21bb0cb1af5d1ede9885ced667465ceb582b4918cd323c291c2c1dd", + "receipt": { + "to": null, + "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "contractAddress": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + "transactionIndex": 0, + "gasUsed": "127213", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x96d19bd18da09b687cf1ef0d792277fc649c8762ccacfc065c82e8403ba6d3ab", + "transactionHash": "0x8bec9208c21bb0cb1af5d1ede9885ced667465ceb582b4918cd323c291c2c1dd", + "logs": [], + "blockNumber": 4, + "cumulativeGasUsed": "127213", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "a5a4b4fb9b01e798eddcfdb1da63d0bc", + "metadata": "{\"compiler\":{\"version\":\"0.8.18+commit.87f61d96\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/router/DiamondInit.sol\":\"DiamondInit\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":4294967295},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\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\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamond {\\n enum FacetCutAction {Add, Replace, Remove}\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\\n}\",\"keccak256\":\"0x37be579b243559c0c16a8de037d2c428e8fafdfdd9cde69fa165a07f5adfda2c\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport { IDiamond } from \\\"./IDiamond.sol\\\";\\n\\ninterface IDiamondCut is IDiamond { \\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external; \\n}\\n\",\"keccak256\":\"0x9ecd4a637b7cb44c26a4ab7760766defce42a6dc36a355b92dfeef9ce4391fee\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondLoupe.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\n// A loupe is a small magnifying glass used to look at diamonds.\\n// These functions look at diamonds\\ninterface IDiamondLoupe {\\n /// These functions are expected to be called frequently\\n /// by tools.\\n\\n struct Facet {\\n address facetAddress;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Gets all facet addresses and their four byte function selectors.\\n /// @return facets_ Facet\\n function facets() external view returns (Facet[] memory facets_);\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return facetFunctionSelectors_\\n function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses() external view returns (address[] memory facetAddresses_);\\n\\n /// @notice Gets the facet that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);\\n}\\n\",\"keccak256\":\"0x10884024af2c0f7deca0fac4ddf84e76da5dba35b6e02fabeac8ea54c1a5c6f7\",\"license\":\"MIT\"},\"contracts/router/DiamondInit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\nimport { LibDiamond } from \\\"../storage/LibDiamond.sol\\\";\\nimport { IDiamondLoupe } from \\\"../interfaces/IDiamondLoupe.sol\\\";\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\ncontract DiamondInit {\\n function init() external {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n ds.supportedInterfaces[type(IERC165).interfaceId] = true;\\n ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;\\n ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;\\n }\\n}\\n\",\"keccak256\":\"0xdd2d505e77d209c8bf3d3555d1e7506851c461663dfb5cf3653d0a7a3cdf3585\",\"license\":\"MIT\"},\"contracts/storage/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport { IDiamond } from \\\"../interfaces/IDiamond.sol\\\";\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\\n// The loupe functions are required by the EIP2535 Diamonds standard\\n\\nerror NoSelectorsGivenToAdd();\\nerror NotContractOwner(address _user, address _contractOwner);\\nerror NoSelectorsProvidedForFacetForCut(address _facetAddress);\\nerror CannotAddSelectorsToZeroAddress(bytes4[] _selectors);\\nerror NoBytecodeAtAddress(address _contractAddress, string _message);\\nerror IncorrectFacetCutAction(uint8 _action);\\nerror CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);\\nerror CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);\\nerror CannotReplaceImmutableFunction(bytes4 _selector);\\nerror CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);\\nerror CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);\\nerror RemoveFacetAddressMustBeZeroAddress(address _facetAddress);\\nerror CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);\\nerror CannotRemoveImmutableFunction(bytes4 _selector);\\nerror InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct FacetAddressAndSelectorPosition {\\n address facetAddress;\\n uint16 selectorPosition;\\n }\\n\\n struct DiamondStorage {\\n // function selector => facet address and selector position in selectors array\\n mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;\\n bytes4[] selectors;\\n mapping(bytes4 => bool) supportedInterfaces;\\n address contractOwner;\\n }\\n\\n function diamondStorage() internal pure returns (DiamondStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n if (msg.sender != diamondStorage().contractOwner) {\\n revert NotContractOwner(msg.sender, diamondStorage().contractOwner);\\n }\\n }\\n\\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);\\n\\n // Internal function version of diamondCut\\n function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {\\n for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\\n bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors;\\n address facetAddress = _diamondCut[facetIndex].facetAddress;\\n if (functionSelectors.length == 0) {\\n revert NoSelectorsProvidedForFacetForCut(facetAddress);\\n }\\n IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;\\n if (action == IDiamond.FacetCutAction.Add) {\\n addFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Replace) {\\n replaceFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Remove) {\\n removeFunctions(facetAddress, functionSelectors);\\n } else {\\n revert IncorrectFacetCutAction(uint8(action));\\n }\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n if (_facetAddress == address(0)) {\\n revert CannotAddSelectorsToZeroAddress(_functionSelectors);\\n }\\n DiamondStorage storage ds = diamondStorage();\\n uint16 selectorCount = uint16(ds.selectors.length);\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Add facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n if (oldFacetAddress != address(0)) {\\n revert CannotAddFunctionToDiamondThatAlreadyExists(selector);\\n }\\n ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(\\n _facetAddress,\\n selectorCount\\n );\\n ds.selectors.push(selector);\\n selectorCount++;\\n }\\n }\\n\\n function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n if (_facetAddress == address(0)) {\\n revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);\\n }\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Replace facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n // can't replace immutable functions -- functions defined directly in the diamond in this case\\n if (oldFacetAddress == address(this)) {\\n revert CannotReplaceImmutableFunction(selector);\\n }\\n if (oldFacetAddress == _facetAddress) {\\n revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);\\n }\\n if (oldFacetAddress == address(0)) {\\n revert CannotReplaceFunctionThatDoesNotExists(selector);\\n }\\n // replace old facet address\\n ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress;\\n }\\n }\\n\\n function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n if (_facetAddress != address(0)) {\\n revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);\\n }\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds\\n .facetAddressAndSelectorPosition[selector];\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {\\n revert CannotRemoveFunctionThatDoesNotExist(selector);\\n }\\n\\n // can't remove immutable functions -- functions defined directly in the diamond\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {\\n revert CannotRemoveImmutableFunction(selector);\\n }\\n // replace selector with last selector\\n selectorCount--;\\n if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {\\n bytes4 lastSelector = ds.selectors[selectorCount];\\n ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;\\n ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition\\n .selectorPosition;\\n }\\n // delete last selector\\n ds.selectors.pop();\\n delete ds.facetAddressAndSelectorPosition[selector];\\n }\\n }\\n\\n function initializeDiamondCut(address _init, bytes memory _calldata) internal {\\n if (_init == address(0)) {\\n return;\\n }\\n enforceHasContractCode(_init, \\\"LibDiamondCut: _init address has no code\\\");\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up error\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(error)\\n revert(add(32, error), returndata_size)\\n }\\n } else {\\n revert InitializationFunctionReverted(_init, _calldata);\\n }\\n }\\n }\\n\\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n if (contractSize == 0) {\\n revert NoBytecodeAtAddress(_contract, _errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4a4aa3ee1fa8366a19930b6b98cce435187052d142312a03db92ef9d27fb1b69\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610157806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e1c7392a14610030575b600080fd5b61011f7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e6020527f673a26ab9c976db950bbe987aa80c5e387f329563bb0afe093ddccc970489e31805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091821681179092557f9bed265332efc30fa7643cc339edc91cb284a0f6566818a5788922af58c86b5080548216831790557f48e2b093000000000000000000000000000000000000000000000000000000006000527f795db15802e151b19272d3e7b72ebd9d0cedc282cc23a6e937c8c3c90d9e213780549091169091179055565b00fea2646970667358221220d31120b8582da304c493d4af7f0f1a0ab27b3a05f37966a524e6b1f96bdc6ca564736f6c63430008120033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e1c7392a14610030575b600080fd5b61011f7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e6020527f673a26ab9c976db950bbe987aa80c5e387f329563bb0afe093ddccc970489e31805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091821681179092557f9bed265332efc30fa7643cc339edc91cb284a0f6566818a5788922af58c86b5080548216831790557f48e2b093000000000000000000000000000000000000000000000000000000006000527f795db15802e151b19272d3e7b72ebd9d0cedc282cc23a6e937c8c3c90d9e213780549091169091179055565b00fea2646970667358221220d31120b8582da304c493d4af7f0f1a0ab27b3a05f37966a524e6b1f96bdc6ca564736f6c63430008120033", + "libraries": { + "LibDiamond": "0x5FbDB2315678afecb367f032d93F642f64180aa3" + }, + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/apps/protocol/deployments/localhost/DiamondLoupeFacet.json b/apps/protocol/deployments/localhost/DiamondLoupeFacet.json new file mode 100644 index 000000000..9f49c1e79 --- /dev/null +++ b/apps/protocol/deployments/localhost/DiamondLoupeFacet.json @@ -0,0 +1,180 @@ +{ + "address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "facetAddress", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facetAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "facetAddresses_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facet", + "type": "address" + } + ], + "name": "facetFunctionSelectors", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "_facetFunctionSelectors", + "type": "bytes4[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facets", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondLoupe.Facet[]", + "name": "facets_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x43d85e877f16e38451f28f48be7331b720faa877c598938f4054fb9e4c7119db", + "receipt": { + "to": null, + "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "contractAddress": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", + "transactionIndex": 0, + "gasUsed": "771786", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x716c00eb0a2eb0ccd7ed8b22206968b0c4cac94f25251ee7c21253aa577c9a74", + "transactionHash": "0x43d85e877f16e38451f28f48be7331b720faa877c598938f4054fb9e4c7119db", + "logs": [], + "blockNumber": 3, + "cumulativeGasUsed": "771786", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "51a2a82961a43c75be79c94bce10e613", + "metadata": "{\"compiler\":{\"version\":\"0.8.18+commit.87f61d96\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_functionSelector\",\"type\":\"bytes4\"}],\"name\":\"facetAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"facetAddress_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"facetAddresses\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"facetAddresses_\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_facet\",\"type\":\"address\"}],\"name\":\"facetFunctionSelectors\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"_facetFunctionSelectors\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"facets\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"internalType\":\"struct IDiamondLoupe.Facet[]\",\"name\":\"facets_\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"facetAddress(bytes4)\":{\"details\":\"If facet is not found return address(0).\",\"params\":{\"_functionSelector\":\"The function selector.\"},\"returns\":{\"facetAddress_\":\"The facet address.\"}},\"facetAddresses()\":{\"returns\":{\"facetAddresses_\":\"facetAddresses_\"}},\"facetFunctionSelectors(address)\":{\"params\":{\"_facet\":\"The facet address.\"},\"returns\":{\"_facetFunctionSelectors\":\"The selectors associated with a facet address.\"}},\"facets()\":{\"returns\":{\"facets_\":\"Facet\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"facetAddress(bytes4)\":{\"notice\":\"Gets the facet address that supports the given selector.\"},\"facetAddresses()\":{\"notice\":\"Get all the facet addresses used by a diamond.\"},\"facetFunctionSelectors(address)\":{\"notice\":\"Gets all the function selectors supported by a specific facet.\"},\"facets()\":{\"notice\":\"Gets all facets and their selectors.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/DiamondLoupeFacet.sol\":\"DiamondLoupeFacet\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":4294967295},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\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\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/facets/DiamondLoupeFacet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\n// The functions in DiamondLoupeFacet MUST be added to a diamond.\\n// The EIP-2535 Diamond standard requires these functions.\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\nimport { LibDiamond } from \\\"../storage/LibDiamond.sol\\\";\\nimport { IDiamondLoupe } from \\\"../interfaces/IDiamondLoupe.sol\\\";\\n\\ncontract DiamondLoupeFacet is IDiamondLoupe, IERC165 {\\n // Diamond Loupe Functions\\n ////////////////////////////////////////////////////////////////////\\n /// These functions are expected to be called frequently by tools.\\n //\\n // struct Facet {\\n // address facetAddress;\\n // bytes4[] functionSelectors;\\n // }\\n /// @notice Gets all facets and their selectors.\\n /// @return facets_ Facet\\n function facets() external override view returns (Facet[] memory facets_) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n // create an array set to the maximum size possible\\n facets_ = new Facet[](selectorCount);\\n // create an array for counting the number of selectors for each facet\\n uint16[] memory numFacetSelectors = new uint16[](selectorCount);\\n // total number of facets\\n uint256 numFacets;\\n // loop through function selectors\\n for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) {\\n bytes4 selector = ds.selectors[selectorIndex];\\n address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n bool continueLoop = false;\\n // find the functionSelectors array for selector and add selector to it\\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\\n if (facets_[facetIndex].facetAddress == facetAddress_) {\\n facets_[facetIndex].functionSelectors[numFacetSelectors[facetIndex]] = selector; \\n numFacetSelectors[facetIndex]++;\\n continueLoop = true;\\n break;\\n }\\n }\\n // if functionSelectors array exists for selector then continue loop\\n if (continueLoop) {\\n continueLoop = false;\\n continue;\\n }\\n // create a new functionSelectors array for selector\\n facets_[numFacets].facetAddress = facetAddress_;\\n facets_[numFacets].functionSelectors = new bytes4[](selectorCount);\\n facets_[numFacets].functionSelectors[0] = selector;\\n numFacetSelectors[numFacets] = 1;\\n numFacets++;\\n }\\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\\n uint256 numSelectors = numFacetSelectors[facetIndex];\\n bytes4[] memory selectors = facets_[facetIndex].functionSelectors;\\n // setting the number of selectors\\n assembly {\\n mstore(selectors, numSelectors)\\n }\\n }\\n // setting the number of facets\\n assembly {\\n mstore(facets_, numFacets)\\n }\\n }\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return _facetFunctionSelectors The selectors associated with a facet address.\\n function facetFunctionSelectors(address _facet) external override view returns (bytes4[] memory _facetFunctionSelectors) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n uint256 numSelectors;\\n _facetFunctionSelectors = new bytes4[](selectorCount);\\n // loop through function selectors\\n for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) {\\n bytes4 selector = ds.selectors[selectorIndex];\\n address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n if (_facet == facetAddress_) {\\n _facetFunctionSelectors[numSelectors] = selector;\\n numSelectors++;\\n }\\n }\\n // Set the number of selectors in the array\\n assembly {\\n mstore(_facetFunctionSelectors, numSelectors)\\n }\\n }\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses() external override view returns (address[] memory facetAddresses_) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n // create an array set to the maximum size possible\\n facetAddresses_ = new address[](selectorCount);\\n uint256 numFacets;\\n // loop through function selectors\\n for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) {\\n bytes4 selector = ds.selectors[selectorIndex];\\n address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n bool continueLoop = false;\\n // see if we have collected the address already and break out of loop if we have\\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\\n if (facetAddress_ == facetAddresses_[facetIndex]) {\\n continueLoop = true;\\n break;\\n }\\n }\\n // continue loop if we already have the address\\n if (continueLoop) {\\n continueLoop = false;\\n continue;\\n }\\n // include address\\n facetAddresses_[numFacets] = facetAddress_;\\n numFacets++;\\n }\\n // Set the number of facet addresses in the array\\n assembly {\\n mstore(facetAddresses_, numFacets)\\n }\\n }\\n\\n /// @notice Gets the facet address that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(bytes4 _functionSelector) external override view returns (address facetAddress_) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n facetAddress_ = ds.facetAddressAndSelectorPosition[_functionSelector].facetAddress;\\n }\\n\\n // This implements ERC-165.\\n function supportsInterface(bytes4 _interfaceId) external override view returns (bool) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n return ds.supportedInterfaces[_interfaceId];\\n }\\n}\\n\",\"keccak256\":\"0x1688163a3422d3a5293bb71b08188d213787acb37eccb4c242c102ee7c810085\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamond {\\n enum FacetCutAction {Add, Replace, Remove}\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\\n}\",\"keccak256\":\"0x37be579b243559c0c16a8de037d2c428e8fafdfdd9cde69fa165a07f5adfda2c\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport { IDiamond } from \\\"./IDiamond.sol\\\";\\n\\ninterface IDiamondCut is IDiamond { \\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external; \\n}\\n\",\"keccak256\":\"0x9ecd4a637b7cb44c26a4ab7760766defce42a6dc36a355b92dfeef9ce4391fee\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondLoupe.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\n// A loupe is a small magnifying glass used to look at diamonds.\\n// These functions look at diamonds\\ninterface IDiamondLoupe {\\n /// These functions are expected to be called frequently\\n /// by tools.\\n\\n struct Facet {\\n address facetAddress;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Gets all facet addresses and their four byte function selectors.\\n /// @return facets_ Facet\\n function facets() external view returns (Facet[] memory facets_);\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return facetFunctionSelectors_\\n function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses() external view returns (address[] memory facetAddresses_);\\n\\n /// @notice Gets the facet that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);\\n}\\n\",\"keccak256\":\"0x10884024af2c0f7deca0fac4ddf84e76da5dba35b6e02fabeac8ea54c1a5c6f7\",\"license\":\"MIT\"},\"contracts/storage/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport { IDiamond } from \\\"../interfaces/IDiamond.sol\\\";\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\\n// The loupe functions are required by the EIP2535 Diamonds standard\\n\\nerror NoSelectorsGivenToAdd();\\nerror NotContractOwner(address _user, address _contractOwner);\\nerror NoSelectorsProvidedForFacetForCut(address _facetAddress);\\nerror CannotAddSelectorsToZeroAddress(bytes4[] _selectors);\\nerror NoBytecodeAtAddress(address _contractAddress, string _message);\\nerror IncorrectFacetCutAction(uint8 _action);\\nerror CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);\\nerror CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);\\nerror CannotReplaceImmutableFunction(bytes4 _selector);\\nerror CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);\\nerror CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);\\nerror RemoveFacetAddressMustBeZeroAddress(address _facetAddress);\\nerror CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);\\nerror CannotRemoveImmutableFunction(bytes4 _selector);\\nerror InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct FacetAddressAndSelectorPosition {\\n address facetAddress;\\n uint16 selectorPosition;\\n }\\n\\n struct DiamondStorage {\\n // function selector => facet address and selector position in selectors array\\n mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;\\n bytes4[] selectors;\\n mapping(bytes4 => bool) supportedInterfaces;\\n address contractOwner;\\n }\\n\\n function diamondStorage() internal pure returns (DiamondStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n if (msg.sender != diamondStorage().contractOwner) {\\n revert NotContractOwner(msg.sender, diamondStorage().contractOwner);\\n }\\n }\\n\\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);\\n\\n // Internal function version of diamondCut\\n function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {\\n for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\\n bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors;\\n address facetAddress = _diamondCut[facetIndex].facetAddress;\\n if (functionSelectors.length == 0) {\\n revert NoSelectorsProvidedForFacetForCut(facetAddress);\\n }\\n IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;\\n if (action == IDiamond.FacetCutAction.Add) {\\n addFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Replace) {\\n replaceFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Remove) {\\n removeFunctions(facetAddress, functionSelectors);\\n } else {\\n revert IncorrectFacetCutAction(uint8(action));\\n }\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n if (_facetAddress == address(0)) {\\n revert CannotAddSelectorsToZeroAddress(_functionSelectors);\\n }\\n DiamondStorage storage ds = diamondStorage();\\n uint16 selectorCount = uint16(ds.selectors.length);\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Add facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n if (oldFacetAddress != address(0)) {\\n revert CannotAddFunctionToDiamondThatAlreadyExists(selector);\\n }\\n ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(\\n _facetAddress,\\n selectorCount\\n );\\n ds.selectors.push(selector);\\n selectorCount++;\\n }\\n }\\n\\n function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n if (_facetAddress == address(0)) {\\n revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);\\n }\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Replace facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n // can't replace immutable functions -- functions defined directly in the diamond in this case\\n if (oldFacetAddress == address(this)) {\\n revert CannotReplaceImmutableFunction(selector);\\n }\\n if (oldFacetAddress == _facetAddress) {\\n revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);\\n }\\n if (oldFacetAddress == address(0)) {\\n revert CannotReplaceFunctionThatDoesNotExists(selector);\\n }\\n // replace old facet address\\n ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress;\\n }\\n }\\n\\n function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n if (_facetAddress != address(0)) {\\n revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);\\n }\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds\\n .facetAddressAndSelectorPosition[selector];\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {\\n revert CannotRemoveFunctionThatDoesNotExist(selector);\\n }\\n\\n // can't remove immutable functions -- functions defined directly in the diamond\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {\\n revert CannotRemoveImmutableFunction(selector);\\n }\\n // replace selector with last selector\\n selectorCount--;\\n if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {\\n bytes4 lastSelector = ds.selectors[selectorCount];\\n ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;\\n ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition\\n .selectorPosition;\\n }\\n // delete last selector\\n ds.selectors.pop();\\n delete ds.facetAddressAndSelectorPosition[selector];\\n }\\n }\\n\\n function initializeDiamondCut(address _init, bytes memory _calldata) internal {\\n if (_init == address(0)) {\\n return;\\n }\\n enforceHasContractCode(_init, \\\"LibDiamondCut: _init address has no code\\\");\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up error\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(error)\\n revert(add(32, error), returndata_size)\\n }\\n } else {\\n revert InitializationFunctionReverted(_init, _calldata);\\n }\\n }\\n }\\n\\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n if (contractSize == 0) {\\n revert NoBytecodeAtAddress(_contract, _errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4a4aa3ee1fa8366a19930b6b98cce435187052d142312a03db92ef9d27fb1b69\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610d0e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80637a0ed627116100505780637a0ed627146100fa578063adfca15e1461010f578063cdffacc61461012f57600080fd5b806301ffc9a71461006c57806352ef6b2c146100e5575b600080fd5b6100d061007a366004610a01565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100ed6101cb565b6040516100dc9190610a4a565b6101026103ca565b6040516100dc9190610b01565b61012261011d366004610ba9565b610869565b6040516100dc9190610bdf565b6101a661013d366004610a01565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100dc565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d546060907fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c908067ffffffffffffffff81111561022b5761022b610bf2565b604051908082528060200260200182016040528015610254578160200160208202803683370190505b5092506000805b828110156103c057600084600101828154811061027a5761027a610c21565b6000918252602080832060088304015460079092166004026101000a90910460e01b7fffffffff000000000000000000000000000000000000000000000000000000008116835290879052604082205490925073ffffffffffffffffffffffffffffffffffffffff1690805b858110156103555788818151811061030057610300610c21565b602002602001015173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036103435760019150610355565b8061034d81610c7f565b9150506102e6565b50801561036557506103ae915050565b8188868151811061037857610378610c21565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152846103a781610c7f565b9550505050505b806103b881610c7f565b91505061025b565b5080845250505090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d546060907fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c908067ffffffffffffffff81111561042a5761042a610bf2565b60405190808252806020026020018201604052801561047057816020015b6040805180820190915260008152606060208201528152602001906001900390816104485790505b50925060008167ffffffffffffffff81111561048e5761048e610bf2565b6040519080825280602002602001820160405280156104b7578160200160208202803683370190505b5090506000805b838110156107f65760008560010182815481106104dd576104dd610c21565b6000918252602080832060088304015460079092166004026101000a90910460e01b7fffffffff000000000000000000000000000000000000000000000000000000008116835290889052604082205490925073ffffffffffffffffffffffffffffffffffffffff1690805b85811015610683578273ffffffffffffffffffffffffffffffffffffffff168a828151811061057a5761057a610c21565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff160361067157838a82815181106105b4576105b4610c21565b6020026020010151602001518883815181106105d2576105d2610c21565b602002602001015161ffff16815181106105ee576105ee610c21565b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505086818151811061064c5761064c610c21565b60200260200101805180919061066190610cb7565b61ffff1690525060019150610683565b8061067b81610c7f565b915050610549565b50801561069357506107e4915050565b818986815181106106a6576106a6610c21565b602090810291909101015173ffffffffffffffffffffffffffffffffffffffff90911690528667ffffffffffffffff8111156106e4576106e4610bf2565b60405190808252806020026020018201604052801561070d578160200160208202803683370190505b5089868151811061072057610720610c21565b6020026020010151602001819052508289868151811061074257610742610c21565b60200260200101516020015160008151811061076057610760610c21565b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060018686815181106107c0576107c0610c21565b61ffff90921660209283029190910190910152846107dd81610c7f565b9550505050505b806107ee81610c7f565b9150506104be565b5060005b8181101561085e57600083828151811061081657610816610c21565b602002602001015161ffff169050600087838151811061083857610838610c21565b60200260200101516020015190508181525050808061085690610c7f565b9150506107fa565b508085525050505090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d546060907fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9060008167ffffffffffffffff8111156108cb576108cb610bf2565b6040519080825280602002602001820160405280156108f4578160200160208202803683370190505b50935060005b828110156109f657600084600101828154811061091957610919610c21565b6000918252602080832060088304015460079092166004026101000a90910460e01b7fffffffff00000000000000000000000000000000000000000000000000000000811683529087905260409091205490915073ffffffffffffffffffffffffffffffffffffffff9081169088168190036109e157818785815181106109a2576109a2610c21565b7fffffffff0000000000000000000000000000000000000000000000000000000090921660209283029190910190910152836109dd81610c7f565b9450505b505080806109ee90610c7f565b9150506108fa565b508352509092915050565b600060208284031215610a1357600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610a4357600080fd5b9392505050565b6020808252825182820181905260009190848201906040850190845b81811015610a9857835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610a66565b50909695505050505050565b600081518084526020808501945080840160005b83811015610af65781517fffffffff000000000000000000000000000000000000000000000000000000001687529582019590820190600101610ab8565b509495945050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015610b9b578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00185528151805173ffffffffffffffffffffffffffffffffffffffff168452870151878401879052610b8887850182610aa4565b9588019593505090860190600101610b28565b509098975050505050505050565b600060208284031215610bbb57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610a4357600080fd5b602081526000610a436020830184610aa4565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610cb057610cb0610c50565b5060010190565b600061ffff808316818103610cce57610cce610c50565b600101939250505056fea26469706673582212208e0ba30f62cc8536f30cc6d1adcf20ee0e1b57e5f8c6a394ae35380a956aa51464736f6c63430008120033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c80637a0ed627116100505780637a0ed627146100fa578063adfca15e1461010f578063cdffacc61461012f57600080fd5b806301ffc9a71461006c57806352ef6b2c146100e5575b600080fd5b6100d061007a366004610a01565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100ed6101cb565b6040516100dc9190610a4a565b6101026103ca565b6040516100dc9190610b01565b61012261011d366004610ba9565b610869565b6040516100dc9190610bdf565b6101a661013d366004610a01565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100dc565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d546060907fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c908067ffffffffffffffff81111561022b5761022b610bf2565b604051908082528060200260200182016040528015610254578160200160208202803683370190505b5092506000805b828110156103c057600084600101828154811061027a5761027a610c21565b6000918252602080832060088304015460079092166004026101000a90910460e01b7fffffffff000000000000000000000000000000000000000000000000000000008116835290879052604082205490925073ffffffffffffffffffffffffffffffffffffffff1690805b858110156103555788818151811061030057610300610c21565b602002602001015173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036103435760019150610355565b8061034d81610c7f565b9150506102e6565b50801561036557506103ae915050565b8188868151811061037857610378610c21565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152846103a781610c7f565b9550505050505b806103b881610c7f565b91505061025b565b5080845250505090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d546060907fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c908067ffffffffffffffff81111561042a5761042a610bf2565b60405190808252806020026020018201604052801561047057816020015b6040805180820190915260008152606060208201528152602001906001900390816104485790505b50925060008167ffffffffffffffff81111561048e5761048e610bf2565b6040519080825280602002602001820160405280156104b7578160200160208202803683370190505b5090506000805b838110156107f65760008560010182815481106104dd576104dd610c21565b6000918252602080832060088304015460079092166004026101000a90910460e01b7fffffffff000000000000000000000000000000000000000000000000000000008116835290889052604082205490925073ffffffffffffffffffffffffffffffffffffffff1690805b85811015610683578273ffffffffffffffffffffffffffffffffffffffff168a828151811061057a5761057a610c21565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff160361067157838a82815181106105b4576105b4610c21565b6020026020010151602001518883815181106105d2576105d2610c21565b602002602001015161ffff16815181106105ee576105ee610c21565b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505086818151811061064c5761064c610c21565b60200260200101805180919061066190610cb7565b61ffff1690525060019150610683565b8061067b81610c7f565b915050610549565b50801561069357506107e4915050565b818986815181106106a6576106a6610c21565b602090810291909101015173ffffffffffffffffffffffffffffffffffffffff90911690528667ffffffffffffffff8111156106e4576106e4610bf2565b60405190808252806020026020018201604052801561070d578160200160208202803683370190505b5089868151811061072057610720610c21565b6020026020010151602001819052508289868151811061074257610742610c21565b60200260200101516020015160008151811061076057610760610c21565b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060018686815181106107c0576107c0610c21565b61ffff90921660209283029190910190910152846107dd81610c7f565b9550505050505b806107ee81610c7f565b9150506104be565b5060005b8181101561085e57600083828151811061081657610816610c21565b602002602001015161ffff169050600087838151811061083857610838610c21565b60200260200101516020015190508181525050808061085690610c7f565b9150506107fa565b508085525050505090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d546060907fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9060008167ffffffffffffffff8111156108cb576108cb610bf2565b6040519080825280602002602001820160405280156108f4578160200160208202803683370190505b50935060005b828110156109f657600084600101828154811061091957610919610c21565b6000918252602080832060088304015460079092166004026101000a90910460e01b7fffffffff00000000000000000000000000000000000000000000000000000000811683529087905260409091205490915073ffffffffffffffffffffffffffffffffffffffff9081169088168190036109e157818785815181106109a2576109a2610c21565b7fffffffff0000000000000000000000000000000000000000000000000000000090921660209283029190910190910152836109dd81610c7f565b9450505b505080806109ee90610c7f565b9150506108fa565b508352509092915050565b600060208284031215610a1357600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610a4357600080fd5b9392505050565b6020808252825182820181905260009190848201906040850190845b81811015610a9857835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610a66565b50909695505050505050565b600081518084526020808501945080840160005b83811015610af65781517fffffffff000000000000000000000000000000000000000000000000000000001687529582019590820190600101610ab8565b509495945050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015610b9b578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00185528151805173ffffffffffffffffffffffffffffffffffffffff168452870151878401879052610b8887850182610aa4565b9588019593505090860190600101610b28565b509098975050505050505050565b600060208284031215610bbb57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610a4357600080fd5b602081526000610a436020830184610aa4565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610cb057610cb0610c50565b5060010190565b600061ffff808316818103610cce57610cce610c50565b600101939250505056fea26469706673582212208e0ba30f62cc8536f30cc6d1adcf20ee0e1b57e5f8c6a394ae35380a956aa51464736f6c63430008120033", + "libraries": { + "LibDiamond": "0x5FbDB2315678afecb367f032d93F642f64180aa3" + }, + "devdoc": { + "kind": "dev", + "methods": { + "facetAddress(bytes4)": { + "details": "If facet is not found return address(0).", + "params": { + "_functionSelector": "The function selector." + }, + "returns": { + "facetAddress_": "The facet address." + } + }, + "facetAddresses()": { + "returns": { + "facetAddresses_": "facetAddresses_" + } + }, + "facetFunctionSelectors(address)": { + "params": { + "_facet": "The facet address." + }, + "returns": { + "_facetFunctionSelectors": "The selectors associated with a facet address." + } + }, + "facets()": { + "returns": { + "facets_": "Facet" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "facetAddress(bytes4)": { + "notice": "Gets the facet address that supports the given selector." + }, + "facetAddresses()": { + "notice": "Get all the facet addresses used by a diamond." + }, + "facetFunctionSelectors(address)": { + "notice": "Gets all the function selectors supported by a specific facet." + }, + "facets()": { + "notice": "Gets all facets and their selectors." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/apps/protocol/deployments/localhost/LibDiamond.json b/apps/protocol/deployments/localhost/LibDiamond.json new file mode 100644 index 000000000..64e5c8e61 --- /dev/null +++ b/apps/protocol/deployments/localhost/LibDiamond.json @@ -0,0 +1,103 @@ +{ + "address": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamond.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamond.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": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + } + ], + "transactionHash": "0xe1cd6d2169cecb9a5cee3af504523668e31f248c43b5a3a63f06840e60fa45a0", + "receipt": { + "to": null, + "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "transactionIndex": 0, + "gasUsed": "72227", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x21dd8a57f3b9e3612035e2dd428c5848c2effc7386f09fe21dd86ed2375be975", + "transactionHash": "0xe1cd6d2169cecb9a5cee3af504523668e31f248c43b5a3a63f06840e60fa45a0", + "logs": [], + "blockNumber": 1, + "cumulativeGasUsed": "72227", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "51a2a82961a43c75be79c94bce10e613", + "metadata": "{\"compiler\":{\"version\":\"0.8.18+commit.87f61d96\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"enum IDiamond.FacetCutAction\",\"name\":\"action\",\"type\":\"uint8\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"indexed\":false,\"internalType\":\"struct IDiamond.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\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/storage/LibDiamond.sol\":\"LibDiamond\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":4294967295},\"remappings\":[]},\"sources\":{\"contracts/interfaces/IDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamond {\\n enum FacetCutAction {Add, Replace, Remove}\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\\n}\",\"keccak256\":\"0x37be579b243559c0c16a8de037d2c428e8fafdfdd9cde69fa165a07f5adfda2c\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport { IDiamond } from \\\"./IDiamond.sol\\\";\\n\\ninterface IDiamondCut is IDiamond { \\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external; \\n}\\n\",\"keccak256\":\"0x9ecd4a637b7cb44c26a4ab7760766defce42a6dc36a355b92dfeef9ce4391fee\",\"license\":\"MIT\"},\"contracts/storage/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport { IDiamond } from \\\"../interfaces/IDiamond.sol\\\";\\nimport { IDiamondCut } from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\\n// The loupe functions are required by the EIP2535 Diamonds standard\\n\\nerror NoSelectorsGivenToAdd();\\nerror NotContractOwner(address _user, address _contractOwner);\\nerror NoSelectorsProvidedForFacetForCut(address _facetAddress);\\nerror CannotAddSelectorsToZeroAddress(bytes4[] _selectors);\\nerror NoBytecodeAtAddress(address _contractAddress, string _message);\\nerror IncorrectFacetCutAction(uint8 _action);\\nerror CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);\\nerror CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);\\nerror CannotReplaceImmutableFunction(bytes4 _selector);\\nerror CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);\\nerror CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);\\nerror RemoveFacetAddressMustBeZeroAddress(address _facetAddress);\\nerror CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);\\nerror CannotRemoveImmutableFunction(bytes4 _selector);\\nerror InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct FacetAddressAndSelectorPosition {\\n address facetAddress;\\n uint16 selectorPosition;\\n }\\n\\n struct DiamondStorage {\\n // function selector => facet address and selector position in selectors array\\n mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;\\n bytes4[] selectors;\\n mapping(bytes4 => bool) supportedInterfaces;\\n address contractOwner;\\n }\\n\\n function diamondStorage() internal pure returns (DiamondStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n if (msg.sender != diamondStorage().contractOwner) {\\n revert NotContractOwner(msg.sender, diamondStorage().contractOwner);\\n }\\n }\\n\\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);\\n\\n // Internal function version of diamondCut\\n function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {\\n for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\\n bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors;\\n address facetAddress = _diamondCut[facetIndex].facetAddress;\\n if (functionSelectors.length == 0) {\\n revert NoSelectorsProvidedForFacetForCut(facetAddress);\\n }\\n IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;\\n if (action == IDiamond.FacetCutAction.Add) {\\n addFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Replace) {\\n replaceFunctions(facetAddress, functionSelectors);\\n } else if (action == IDiamond.FacetCutAction.Remove) {\\n removeFunctions(facetAddress, functionSelectors);\\n } else {\\n revert IncorrectFacetCutAction(uint8(action));\\n }\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n if (_facetAddress == address(0)) {\\n revert CannotAddSelectorsToZeroAddress(_functionSelectors);\\n }\\n DiamondStorage storage ds = diamondStorage();\\n uint16 selectorCount = uint16(ds.selectors.length);\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Add facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n if (oldFacetAddress != address(0)) {\\n revert CannotAddFunctionToDiamondThatAlreadyExists(selector);\\n }\\n ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(\\n _facetAddress,\\n selectorCount\\n );\\n ds.selectors.push(selector);\\n selectorCount++;\\n }\\n }\\n\\n function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n if (_facetAddress == address(0)) {\\n revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);\\n }\\n enforceHasContractCode(_facetAddress, \\\"LibDiamondCut: Replace facet has no code\\\");\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\\n // can't replace immutable functions -- functions defined directly in the diamond in this case\\n if (oldFacetAddress == address(this)) {\\n revert CannotReplaceImmutableFunction(selector);\\n }\\n if (oldFacetAddress == _facetAddress) {\\n revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);\\n }\\n if (oldFacetAddress == address(0)) {\\n revert CannotReplaceFunctionThatDoesNotExists(selector);\\n }\\n // replace old facet address\\n ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress;\\n }\\n }\\n\\n function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 selectorCount = ds.selectors.length;\\n if (_facetAddress != address(0)) {\\n revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);\\n }\\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\\n bytes4 selector = _functionSelectors[selectorIndex];\\n FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds\\n .facetAddressAndSelectorPosition[selector];\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {\\n revert CannotRemoveFunctionThatDoesNotExist(selector);\\n }\\n\\n // can't remove immutable functions -- functions defined directly in the diamond\\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {\\n revert CannotRemoveImmutableFunction(selector);\\n }\\n // replace selector with last selector\\n selectorCount--;\\n if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {\\n bytes4 lastSelector = ds.selectors[selectorCount];\\n ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;\\n ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition\\n .selectorPosition;\\n }\\n // delete last selector\\n ds.selectors.pop();\\n delete ds.facetAddressAndSelectorPosition[selector];\\n }\\n }\\n\\n function initializeDiamondCut(address _init, bytes memory _calldata) internal {\\n if (_init == address(0)) {\\n return;\\n }\\n enforceHasContractCode(_init, \\\"LibDiamondCut: _init address has no code\\\");\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up error\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(error)\\n revert(add(32, error), returndata_size)\\n }\\n } else {\\n revert InitializationFunctionReverted(_init, _calldata);\\n }\\n }\\n }\\n\\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n if (contractSize == 0) {\\n revert NoBytecodeAtAddress(_contract, _errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4a4aa3ee1fa8366a19930b6b98cce435187052d142312a03db92ef9d27fb1b69\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220bb65be994eee546976279e0b1b3a157b5f81da2e3773549c677ba3e32c6d826564736f6c63430008120033", + "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220bb65be994eee546976279e0b1b3a157b5f81da2e3773549c677ba3e32c6d826564736f6c63430008120033", + "libraries": {}, + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/apps/protocol/deployments/localhost/Multicall3.json b/apps/protocol/deployments/localhost/Multicall3.json new file mode 100644 index 000000000..eb440c728 --- /dev/null +++ b/apps/protocol/deployments/localhost/Multicall3.json @@ -0,0 +1,593 @@ +{ + "address": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", + "abi": [ + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "returnData", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowFailure", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call3[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate3", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowFailure", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call3Value[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate3Value", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "blockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getBasefee", + "outputs": [ + { + "internalType": "uint256", + "name": "basefee", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "chainid", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockCoinbase", + "outputs": [ + { + "internalType": "address", + "name": "coinbase", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockGasLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "gaslimit", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockPrevrandao", + "outputs": [ + { + "internalType": "uint256", + "name": "prevrandao", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getEthBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryAggregate", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryBlockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0x1bcd065d0cb7523212e9e0052d7e2275499cf9bf8b4592198faa36e53727280d", + "receipt": { + "to": null, + "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "contractAddress": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", + "transactionIndex": 0, + "gasUsed": "871504", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xb8f8a3fd029cc7a184d5c37554504e0cffb907da36c5901586965b97a61b8f42", + "transactionHash": "0x1bcd065d0cb7523212e9e0052d7e2275499cf9bf8b4592198faa36e53727280d", + "logs": [], + "blockNumber": 6, + "cumulativeGasUsed": "871504", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "51a2a82961a43c75be79c94bce10e613", + "metadata": "{\"compiler\":{\"version\":\"0.8.18+commit.87f61d96\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes[]\",\"name\":\"returnData\",\"type\":\"bytes[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"allowFailure\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Call3[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate3\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"allowFailure\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Call3Value[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate3Value\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"blockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBasefee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"basefee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"chainid\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockCoinbase\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockGasLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gaslimit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockPrevrandao\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"prevrandao\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getEthBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryAggregate\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryBlockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Michael Elliot Joshua Levine Nick Johnson Andreas Bigger Matt Solomon \",\"details\":\"Multicall & Multicall2 backwards-compatibleAggregate methods are marked `payable` to save 24 gas per call\",\"kind\":\"dev\",\"methods\":{\"aggregate((address,bytes)[])\":{\"params\":{\"calls\":\"An array of Call structs\"},\"returns\":{\"blockNumber\":\"The block number where the calls were executed\",\"returnData\":\"An array of bytes containing the responses\"}},\"aggregate3((address,bool,bytes)[])\":{\"params\":{\"calls\":\"An array of Call3 structs\"},\"returns\":{\"returnData\":\"An array of Result structs\"}},\"aggregate3Value((address,bool,uint256,bytes)[])\":{\"params\":{\"calls\":\"An array of Call3Value structs\"},\"returns\":{\"returnData\":\"An array of Result structs\"}},\"blockAndAggregate((address,bytes)[])\":{\"params\":{\"calls\":\"An array of Call structs\"},\"returns\":{\"blockHash\":\"The hash of the block where the calls were executed\",\"blockNumber\":\"The block number where the calls were executed\",\"returnData\":\"An array of Result structs\"}},\"getBlockHash(uint256)\":{\"params\":{\"blockNumber\":\"The block number\"}},\"tryAggregate(bool,(address,bytes)[])\":{\"params\":{\"calls\":\"An array of Call structs\",\"requireSuccess\":\"If true, require all calls to succeed\"},\"returns\":{\"returnData\":\"An array of Result structs\"}},\"tryBlockAndAggregate(bool,(address,bytes)[])\":{\"params\":{\"calls\":\"An array of Call structs\"},\"returns\":{\"blockHash\":\"The hash of the block where the calls were executed\",\"blockNumber\":\"The block number where the calls were executed\",\"returnData\":\"An array of Result structs\"}}},\"title\":\"Multicall3\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"aggregate((address,bytes)[])\":{\"notice\":\"Backwards-compatible call aggregation with Multicall\"},\"aggregate3((address,bool,bytes)[])\":{\"notice\":\"Aggregate calls, ensuring each returns success if required\"},\"aggregate3Value((address,bool,uint256,bytes)[])\":{\"notice\":\"Aggregate calls with a msg valueReverts if msg.value is less than the sum of the call values\"},\"blockAndAggregate((address,bytes)[])\":{\"notice\":\"Backwards-compatible with Multicall2Aggregate calls and allow failures using tryAggregate\"},\"getBasefee()\":{\"notice\":\"Gets the base fee of the given blockCan revert if the BASEFEE opcode is not implemented by the given chain\"},\"getBlockHash(uint256)\":{\"notice\":\"Returns the block hash for the given block number\"},\"getBlockNumber()\":{\"notice\":\"Returns the block number\"},\"getChainId()\":{\"notice\":\"Returns the chain id\"},\"getCurrentBlockCoinbase()\":{\"notice\":\"Returns the block coinbase\"},\"getCurrentBlockGasLimit()\":{\"notice\":\"Returns the block gas limit\"},\"getCurrentBlockPrevrandao()\":{\"notice\":\"Returns the block prevrandao\"},\"getCurrentBlockTimestamp()\":{\"notice\":\"Returns the block timestamp\"},\"getEthBalance(address)\":{\"notice\":\"Returns the (ETH) balance of a given address\"},\"getLastBlockHash()\":{\"notice\":\"Returns the block hash of the last block\"},\"tryAggregate(bool,(address,bytes)[])\":{\"notice\":\"Backwards-compatible with Multicall2Aggregate calls without requiring success\"},\"tryBlockAndAggregate(bool,(address,bytes)[])\":{\"notice\":\"Backwards-compatible with Multicall2Aggregate calls and allow failures using tryAggregate\"}},\"notice\":\"Aggregate results from multiple function calls\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/mock/Multicall3.sol\":\"Multicall3\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":4294967295},\"remappings\":[]},\"sources\":{\"contracts/mock/Multicall3.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.18;\\n\\n/// @title Multicall3\\n/// @notice Aggregate results from multiple function calls\\n/// @dev Multicall & Multicall2 backwards-compatible\\n/// @dev Aggregate methods are marked `payable` to save 24 gas per call\\n/// @author Michael Elliot \\n/// @author Joshua Levine \\n/// @author Nick Johnson \\n/// @author Andreas Bigger \\n/// @author Matt Solomon \\ncontract Multicall3 {\\n struct Call {\\n address target;\\n bytes callData;\\n }\\n\\n struct Call3 {\\n address target;\\n bool allowFailure;\\n bytes callData;\\n }\\n\\n struct Call3Value {\\n address target;\\n bool allowFailure;\\n uint256 value;\\n bytes callData;\\n }\\n\\n struct Result {\\n bool success;\\n bytes returnData;\\n }\\n\\n /// @notice Backwards-compatible call aggregation with Multicall\\n /// @param calls An array of Call structs\\n /// @return blockNumber The block number where the calls were executed\\n /// @return returnData An array of bytes containing the responses\\n function aggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData) {\\n blockNumber = block.number;\\n uint256 length = calls.length;\\n returnData = new bytes[](length);\\n Call calldata call;\\n for (uint256 i; i < length; ) {\\n bool success;\\n call = calls[i];\\n (success, returnData[i]) = call.target.call(call.callData);\\n require(success, \\\"Multicall3: call failed\\\");\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Backwards-compatible with Multicall2\\n /// @notice Aggregate calls without requiring success\\n /// @param requireSuccess If true, require all calls to succeed\\n /// @param calls An array of Call structs\\n /// @return returnData An array of Result structs\\n function tryAggregate(\\n bool requireSuccess,\\n Call[] calldata calls\\n ) public payable returns (Result[] memory returnData) {\\n uint256 length = calls.length;\\n returnData = new Result[](length);\\n Call calldata call;\\n for (uint256 i; i < length; ) {\\n Result memory result = returnData[i];\\n call = calls[i];\\n (result.success, result.returnData) = call.target.call(call.callData);\\n if (requireSuccess) require(result.success, \\\"Multicall3: call failed\\\");\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Backwards-compatible with Multicall2\\n /// @notice Aggregate calls and allow failures using tryAggregate\\n /// @param calls An array of Call structs\\n /// @return blockNumber The block number where the calls were executed\\n /// @return blockHash The hash of the block where the calls were executed\\n /// @return returnData An array of Result structs\\n function tryBlockAndAggregate(\\n bool requireSuccess,\\n Call[] calldata calls\\n ) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) {\\n blockNumber = block.number;\\n blockHash = blockhash(block.number);\\n returnData = tryAggregate(requireSuccess, calls);\\n }\\n\\n /// @notice Backwards-compatible with Multicall2\\n /// @notice Aggregate calls and allow failures using tryAggregate\\n /// @param calls An array of Call structs\\n /// @return blockNumber The block number where the calls were executed\\n /// @return blockHash The hash of the block where the calls were executed\\n /// @return returnData An array of Result structs\\n function blockAndAggregate(\\n Call[] calldata calls\\n ) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) {\\n (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls);\\n }\\n\\n /// @notice Aggregate calls, ensuring each returns success if required\\n /// @param calls An array of Call3 structs\\n /// @return returnData An array of Result structs\\n function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData) {\\n uint256 length = calls.length;\\n returnData = new Result[](length);\\n Call3 calldata calli;\\n for (uint256 i; i < length; ) {\\n Result memory result = returnData[i];\\n calli = calls[i];\\n (result.success, result.returnData) = calli.target.call(calli.callData);\\n assembly {\\n // Revert if the call fails and failure is not allowed\\n // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)`\\n if iszero(or(calldataload(add(calli, 0x20)), mload(result))) {\\n // set \\\"Error(string)\\\" signature: bytes32(bytes4(keccak256(\\\"Error(string)\\\")))\\n mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000)\\n // set data offset\\n mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)\\n // set length of revert string\\n mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017)\\n // set revert string: bytes32(abi.encodePacked(\\\"Multicall3: call failed\\\"))\\n mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000)\\n revert(0x00, 0x64)\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Aggregate calls with a msg value\\n /// @notice Reverts if msg.value is less than the sum of the call values\\n /// @param calls An array of Call3Value structs\\n /// @return returnData An array of Result structs\\n function aggregate3Value(Call3Value[] calldata calls) public payable returns (Result[] memory returnData) {\\n uint256 valAccumulator;\\n uint256 length = calls.length;\\n returnData = new Result[](length);\\n Call3Value calldata calli;\\n for (uint256 i; i < length; ) {\\n Result memory result = returnData[i];\\n calli = calls[i];\\n uint256 val = calli.value;\\n // Humanity will be a Type V Kardashev Civilization before this overflows - andreas\\n // ~ 10^25 Wei in existence << ~ 10^76 size uint fits in a uint256\\n unchecked {\\n valAccumulator += val;\\n }\\n (result.success, result.returnData) = calli.target.call{ value: val }(calli.callData);\\n assembly {\\n // Revert if the call fails and failure is not allowed\\n // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)`\\n if iszero(or(calldataload(add(calli, 0x20)), mload(result))) {\\n // set \\\"Error(string)\\\" signature: bytes32(bytes4(keccak256(\\\"Error(string)\\\")))\\n mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000)\\n // set data offset\\n mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)\\n // set length of revert string\\n mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017)\\n // set revert string: bytes32(abi.encodePacked(\\\"Multicall3: call failed\\\"))\\n mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000)\\n revert(0x00, 0x84)\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n // Finally, make sure the msg.value = SUM(call[0...i].value)\\n require(msg.value == valAccumulator, \\\"Multicall3: value mismatch\\\");\\n }\\n\\n /// @notice Returns the block hash for the given block number\\n /// @param blockNumber The block number\\n function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) {\\n blockHash = blockhash(blockNumber);\\n }\\n\\n /// @notice Returns the block number\\n function getBlockNumber() public view returns (uint256 blockNumber) {\\n blockNumber = block.number;\\n }\\n\\n /// @notice Returns the block coinbase\\n function getCurrentBlockCoinbase() public view returns (address coinbase) {\\n coinbase = block.coinbase;\\n }\\n\\n /// @notice Returns the block prevrandao\\n function getCurrentBlockPrevrandao() public view returns (uint256 prevrandao) {\\n prevrandao = block.prevrandao;\\n }\\n\\n /// @notice Returns the block gas limit\\n function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {\\n gaslimit = block.gaslimit;\\n }\\n\\n /// @notice Returns the block timestamp\\n function getCurrentBlockTimestamp() public view returns (uint256 timestamp) {\\n timestamp = block.timestamp;\\n }\\n\\n /// @notice Returns the (ETH) balance of a given address\\n function getEthBalance(address addr) public view returns (uint256 balance) {\\n balance = addr.balance;\\n }\\n\\n /// @notice Returns the block hash of the last block\\n function getLastBlockHash() public view returns (bytes32 blockHash) {\\n unchecked {\\n blockHash = blockhash(block.number - 1);\\n }\\n }\\n\\n /// @notice Gets the base fee of the given block\\n /// @notice Can revert if the BASEFEE opcode is not implemented by the given chain\\n function getBasefee() public view returns (uint256 basefee) {\\n basefee = block.basefee;\\n }\\n\\n /// @notice Returns the chain id\\n function getChainId() public view returns (uint256 chainid) {\\n chainid = block.chainid;\\n }\\n}\\n\",\"keccak256\":\"0x891806f4d01c7c2b45a0f367bad82696c9de12a7cea8a40698ec15ff359a5c76\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610ed9806100206000396000f3fe6080604052600436106100f35760003560e01c806342cbb15c1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b806342cbb15c146101ec5780634d2301cc146101ff57806382ad56cb1461023457806386d516e81461024757600080fd5b806327e86d6e116100c657806327e86d6e1461016e5780633408e470146101a4578063399542e9146101b75780633e64a696146101d957600080fd5b80630ec6ce34146100f85780630f28c97d1461011a578063174dea711461012d578063252dba421461014d575b600080fd5b34801561010457600080fd5b50445b6040519081526020015b60405180910390f35b34801561012657600080fd5b5042610107565b61014061013b366004610a85565b6102ba565b6040516101119190610bb7565b61016061015b366004610a85565b6104ef565b604051610111929190610bd1565b34801561017a57600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b3480156101b057600080fd5b5046610107565b6101ca6101c5366004610c59565b610690565b60405161011193929190610cb3565b3480156101e557600080fd5b5048610107565b3480156101f857600080fd5b5043610107565b34801561020b57600080fd5b5061010761021a366004610cdb565b73ffffffffffffffffffffffffffffffffffffffff163190565b610140610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b610140610283366004610c59565b61085a565b6101ca610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d11565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d2a565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d59565b6020026020010151905087878381811061035d5761035d610d59565b905060200281019061036f9190610d88565b6040810135958601959093506103886020850185610cdb565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dc6565b6040516103ba929190610e2b565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d2a565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d59565b90506020028101906105749190610e3b565b92506105836020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dc6565b6040516105b4929190610e2b565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d59565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d2a565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d59565b6020026020010151905086868381811061074c5761074c610d59565b905060200281019061075e9190610e6f565b925061076d6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dc6565b60405161079e929190610e2b565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d2a565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d59565b602002602001015190508686838181106108fb576108fb610d59565b905060200281019061090d9190610e3b565b925061091c6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dc6565b60405161094d929190610e2b565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600082825180855260208086019550808260051b84010181860160005b84811015610baa578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9681860183610ac7565b9a86019a9450505090830190600101610b48565b5090979650505050505050565b602081526000610bca6020830184610b2b565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c4b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c39868351610ac7565b95509284019290840190600101610bff565b509398975050505050505050565b600080600060408486031215610c6e57600080fd5b83358015158114610c7e57600080fd5b9250602084013567ffffffffffffffff811115610c9a57600080fd5b610ca686828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd26060830184610b2b565b95945050505050565b600060208284031215610ced57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bca57600080fd5b600060208284031215610d2357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dbc57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610dfb57600080fd5b83018035915067ffffffffffffffff821115610e1657600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dbc57600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dbc57600080fdfea26469706673582212207314bac6fd9a72fd7097db011375919b76e15420c0c4373a6b53553b8eef395564736f6c63430008120033", + "deployedBytecode": "0x6080604052600436106100f35760003560e01c806342cbb15c1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b806342cbb15c146101ec5780634d2301cc146101ff57806382ad56cb1461023457806386d516e81461024757600080fd5b806327e86d6e116100c657806327e86d6e1461016e5780633408e470146101a4578063399542e9146101b75780633e64a696146101d957600080fd5b80630ec6ce34146100f85780630f28c97d1461011a578063174dea711461012d578063252dba421461014d575b600080fd5b34801561010457600080fd5b50445b6040519081526020015b60405180910390f35b34801561012657600080fd5b5042610107565b61014061013b366004610a85565b6102ba565b6040516101119190610bb7565b61016061015b366004610a85565b6104ef565b604051610111929190610bd1565b34801561017a57600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b3480156101b057600080fd5b5046610107565b6101ca6101c5366004610c59565b610690565b60405161011193929190610cb3565b3480156101e557600080fd5b5048610107565b3480156101f857600080fd5b5043610107565b34801561020b57600080fd5b5061010761021a366004610cdb565b73ffffffffffffffffffffffffffffffffffffffff163190565b610140610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b610140610283366004610c59565b61085a565b6101ca610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d11565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d2a565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d59565b6020026020010151905087878381811061035d5761035d610d59565b905060200281019061036f9190610d88565b6040810135958601959093506103886020850185610cdb565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dc6565b6040516103ba929190610e2b565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d2a565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d59565b90506020028101906105749190610e3b565b92506105836020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dc6565b6040516105b4929190610e2b565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d59565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d2a565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d59565b6020026020010151905086868381811061074c5761074c610d59565b905060200281019061075e9190610e6f565b925061076d6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dc6565b60405161079e929190610e2b565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d2a565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d59565b602002602001015190508686838181106108fb576108fb610d59565b905060200281019061090d9190610e3b565b925061091c6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dc6565b60405161094d929190610e2b565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600082825180855260208086019550808260051b84010181860160005b84811015610baa578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9681860183610ac7565b9a86019a9450505090830190600101610b48565b5090979650505050505050565b602081526000610bca6020830184610b2b565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c4b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c39868351610ac7565b95509284019290840190600101610bff565b509398975050505050505050565b600080600060408486031215610c6e57600080fd5b83358015158114610c7e57600080fd5b9250602084013567ffffffffffffffff811115610c9a57600080fd5b610ca686828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd26060830184610b2b565b95945050505050565b600060208284031215610ced57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bca57600080fd5b600060208284031215610d2357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dbc57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610dfb57600080fd5b83018035915067ffffffffffffffff821115610e1657600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dbc57600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dbc57600080fdfea26469706673582212207314bac6fd9a72fd7097db011375919b76e15420c0c4373a6b53553b8eef395564736f6c63430008120033", + "libraries": {}, + "devdoc": { + "author": "Michael Elliot Joshua Levine Nick Johnson Andreas Bigger Matt Solomon ", + "details": "Multicall & Multicall2 backwards-compatibleAggregate methods are marked `payable` to save 24 gas per call", + "kind": "dev", + "methods": { + "aggregate((address,bytes)[])": { + "params": { + "calls": "An array of Call structs" + }, + "returns": { + "blockNumber": "The block number where the calls were executed", + "returnData": "An array of bytes containing the responses" + } + }, + "aggregate3((address,bool,bytes)[])": { + "params": { + "calls": "An array of Call3 structs" + }, + "returns": { + "returnData": "An array of Result structs" + } + }, + "aggregate3Value((address,bool,uint256,bytes)[])": { + "params": { + "calls": "An array of Call3Value structs" + }, + "returns": { + "returnData": "An array of Result structs" + } + }, + "blockAndAggregate((address,bytes)[])": { + "params": { + "calls": "An array of Call structs" + }, + "returns": { + "blockHash": "The hash of the block where the calls were executed", + "blockNumber": "The block number where the calls were executed", + "returnData": "An array of Result structs" + } + }, + "getBlockHash(uint256)": { + "params": { + "blockNumber": "The block number" + } + }, + "tryAggregate(bool,(address,bytes)[])": { + "params": { + "calls": "An array of Call structs", + "requireSuccess": "If true, require all calls to succeed" + }, + "returns": { + "returnData": "An array of Result structs" + } + }, + "tryBlockAndAggregate(bool,(address,bytes)[])": { + "params": { + "calls": "An array of Call structs" + }, + "returns": { + "blockHash": "The hash of the block where the calls were executed", + "blockNumber": "The block number where the calls were executed", + "returnData": "An array of Result structs" + } + } + }, + "title": "Multicall3", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "aggregate((address,bytes)[])": { + "notice": "Backwards-compatible call aggregation with Multicall" + }, + "aggregate3((address,bool,bytes)[])": { + "notice": "Aggregate calls, ensuring each returns success if required" + }, + "aggregate3Value((address,bool,uint256,bytes)[])": { + "notice": "Aggregate calls with a msg valueReverts if msg.value is less than the sum of the call values" + }, + "blockAndAggregate((address,bytes)[])": { + "notice": "Backwards-compatible with Multicall2Aggregate calls and allow failures using tryAggregate" + }, + "getBasefee()": { + "notice": "Gets the base fee of the given blockCan revert if the BASEFEE opcode is not implemented by the given chain" + }, + "getBlockHash(uint256)": { + "notice": "Returns the block hash for the given block number" + }, + "getBlockNumber()": { + "notice": "Returns the block number" + }, + "getChainId()": { + "notice": "Returns the chain id" + }, + "getCurrentBlockCoinbase()": { + "notice": "Returns the block coinbase" + }, + "getCurrentBlockGasLimit()": { + "notice": "Returns the block gas limit" + }, + "getCurrentBlockPrevrandao()": { + "notice": "Returns the block prevrandao" + }, + "getCurrentBlockTimestamp()": { + "notice": "Returns the block timestamp" + }, + "getEthBalance(address)": { + "notice": "Returns the (ETH) balance of a given address" + }, + "getLastBlockHash()": { + "notice": "Returns the block hash of the last block" + }, + "tryAggregate(bool,(address,bytes)[])": { + "notice": "Backwards-compatible with Multicall2Aggregate calls without requiring success" + }, + "tryBlockAndAggregate(bool,(address,bytes)[])": { + "notice": "Backwards-compatible with Multicall2Aggregate calls and allow failures using tryAggregate" + } + }, + "notice": "Aggregate results from multiple function calls", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/apps/protocol/deployments/localhost/solcInputs/51a2a82961a43c75be79c94bce10e613.json b/apps/protocol/deployments/localhost/solcInputs/51a2a82961a43c75be79c94bce10e613.json new file mode 100644 index 000000000..9118712f9 --- /dev/null +++ b/apps/protocol/deployments/localhost/solcInputs/51a2a82961a43c75be79c94bce10e613.json @@ -0,0 +1,445 @@ +{ + "language": "Solidity", + "sources": { + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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 * For a generic mechanism see {ERC20PresetMinterPauser}.\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 *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => 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 override 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 override 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 override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override 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 `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` 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 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\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 `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `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 * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(address from, address to, uint256 amount) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` 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 function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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 v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\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 v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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 amount) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\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/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\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 v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\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 denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by 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; // 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 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 // 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 require(denominator > prod1, \"Math: mulDiv overflow\");\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. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\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 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 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 (rounding == Rounding.Up && 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 down.\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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\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 * _Available since v3.4._\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 * _Available since v3.4._\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 * _Available since v3.4._\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 * _Available since v3.4._\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 addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SignedMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\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/math/SignedSafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SignedSafeMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SignedSafeMath` is no longer needed starting with Solidity 0.8. The compiler\n * now has built in overflow checking.\n */\nlibrary SignedSafeMath {\n /**\n * @dev Returns the multiplication of two signed integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(int256 a, int256 b) internal pure returns (int256) {\n return a * b;\n }\n\n /**\n * @dev Returns the integer division of two signed integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(int256 a, int256 b) internal pure returns (int256) {\n return a / b;\n }\n\n /**\n * @dev Returns the subtraction of two signed integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(int256 a, int256 b) internal pure returns (int256) {\n return a - b;\n }\n\n /**\n * @dev Returns the addition of two signed integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(int256 a, int256 b) internal pure returns (int256) {\n return a + b;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\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), _SYMBOLS))\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 toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(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 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] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\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 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 keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableMap.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableMap.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.\n\npragma solidity ^0.8.0;\n\nimport \"./EnumerableSet.sol\";\n\n/**\n * @dev Library for managing an enumerable variant of Solidity's\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\n * type.\n *\n * Maps have the following properties:\n *\n * - Entries are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableMap for EnumerableMap.UintToAddressMap;\n *\n * // Declare a set state variable\n * EnumerableMap.UintToAddressMap private myMap;\n * }\n * ```\n *\n * The following map types are supported:\n *\n * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0\n * - `address -> uint256` (`AddressToUintMap`) since v4.6.0\n * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0\n * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0\n * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableMap.\n * ====\n */\nlibrary EnumerableMap {\n using EnumerableSet for EnumerableSet.Bytes32Set;\n\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Map type with\n // bytes32 keys and values.\n // The Map implementation uses private functions, and user-facing\n // implementations (such as Uint256ToAddressMap) are just wrappers around\n // the underlying Map.\n // This means that we can only create new EnumerableMaps for types that fit\n // in bytes32.\n\n struct Bytes32ToBytes32Map {\n // Storage of keys\n EnumerableSet.Bytes32Set _keys;\n mapping(bytes32 => bytes32) _values;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {\n map._values[key] = value;\n return map._keys.add(key);\n }\n\n /**\n * @dev Removes a key-value pair from a map. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {\n delete map._values[key];\n return map._keys.remove(key);\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {\n return map._keys.contains(key);\n }\n\n /**\n * @dev Returns the number of key-value pairs in the map. O(1).\n */\n function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {\n return map._keys.length();\n }\n\n /**\n * @dev Returns the key-value pair stored at position `index` in the map. O(1).\n *\n * Note that there are no guarantees on the ordering of entries inside the\n * array, and it may change when more entries are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) {\n bytes32 key = map._keys.at(index);\n return (key, map._values[key]);\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n */\n function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {\n bytes32 value = map._values[key];\n if (value == bytes32(0)) {\n return (contains(map, key), bytes32(0));\n } else {\n return (true, value);\n }\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {\n bytes32 value = map._values[key];\n require(value != 0 || contains(map, key), \"EnumerableMap: nonexistent key\");\n return value;\n }\n\n /**\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryGet}.\n */\n function get(\n Bytes32ToBytes32Map storage map,\n bytes32 key,\n string memory errorMessage\n ) internal view returns (bytes32) {\n bytes32 value = map._values[key];\n require(value != 0 || contains(map, key), errorMessage);\n return value;\n }\n\n /**\n * @dev Return the an array containing all the keys\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) {\n return map._keys.values();\n }\n\n // UintToUintMap\n\n struct UintToUintMap {\n Bytes32ToBytes32Map _inner;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {\n return set(map._inner, bytes32(key), bytes32(value));\n }\n\n /**\n * @dev Removes a value from a map. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function remove(UintToUintMap storage map, uint256 key) internal returns (bool) {\n return remove(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) {\n return contains(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns the number of elements in the map. O(1).\n */\n function length(UintToUintMap storage map) internal view returns (uint256) {\n return length(map._inner);\n }\n\n /**\n * @dev Returns the element stored at position `index` in the map. O(1).\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) {\n (bytes32 key, bytes32 value) = at(map._inner, index);\n return (uint256(key), uint256(value));\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n */\n function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {\n (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));\n return (success, uint256(value));\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {\n return uint256(get(map._inner, bytes32(key)));\n }\n\n /**\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryGet}.\n */\n function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) {\n return uint256(get(map._inner, bytes32(key), errorMessage));\n }\n\n /**\n * @dev Return the an array containing all the keys\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function keys(UintToUintMap storage map) internal view returns (uint256[] memory) {\n bytes32[] memory store = keys(map._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintToAddressMap\n\n struct UintToAddressMap {\n Bytes32ToBytes32Map _inner;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\n return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a map. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\n return remove(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\n return contains(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns the number of elements in the map. O(1).\n */\n function length(UintToAddressMap storage map) internal view returns (uint256) {\n return length(map._inner);\n }\n\n /**\n * @dev Returns the element stored at position `index` in the map. O(1).\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\n (bytes32 key, bytes32 value) = at(map._inner, index);\n return (uint256(key), address(uint160(uint256(value))));\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n */\n function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {\n (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));\n return (success, address(uint160(uint256(value))));\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\n return address(uint160(uint256(get(map._inner, bytes32(key)))));\n }\n\n /**\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryGet}.\n */\n function get(\n UintToAddressMap storage map,\n uint256 key,\n string memory errorMessage\n ) internal view returns (address) {\n return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));\n }\n\n /**\n * @dev Return the an array containing all the keys\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) {\n bytes32[] memory store = keys(map._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressToUintMap\n\n struct AddressToUintMap {\n Bytes32ToBytes32Map _inner;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {\n return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));\n }\n\n /**\n * @dev Removes a value from a map. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function remove(AddressToUintMap storage map, address key) internal returns (bool) {\n return remove(map._inner, bytes32(uint256(uint160(key))));\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function contains(AddressToUintMap storage map, address key) internal view returns (bool) {\n return contains(map._inner, bytes32(uint256(uint160(key))));\n }\n\n /**\n * @dev Returns the number of elements in the map. O(1).\n */\n function length(AddressToUintMap storage map) internal view returns (uint256) {\n return length(map._inner);\n }\n\n /**\n * @dev Returns the element stored at position `index` in the map. O(1).\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {\n (bytes32 key, bytes32 value) = at(map._inner, index);\n return (address(uint160(uint256(key))), uint256(value));\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n */\n function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {\n (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));\n return (success, uint256(value));\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function get(AddressToUintMap storage map, address key) internal view returns (uint256) {\n return uint256(get(map._inner, bytes32(uint256(uint160(key)))));\n }\n\n /**\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryGet}.\n */\n function get(\n AddressToUintMap storage map,\n address key,\n string memory errorMessage\n ) internal view returns (uint256) {\n return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));\n }\n\n /**\n * @dev Return the an array containing all the keys\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function keys(AddressToUintMap storage map) internal view returns (address[] memory) {\n bytes32[] memory store = keys(map._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // Bytes32ToUintMap\n\n struct Bytes32ToUintMap {\n Bytes32ToBytes32Map _inner;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {\n return set(map._inner, key, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a map. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) {\n return remove(map._inner, key);\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) {\n return contains(map._inner, key);\n }\n\n /**\n * @dev Returns the number of elements in the map. O(1).\n */\n function length(Bytes32ToUintMap storage map) internal view returns (uint256) {\n return length(map._inner);\n }\n\n /**\n * @dev Returns the element stored at position `index` in the map. O(1).\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {\n (bytes32 key, bytes32 value) = at(map._inner, index);\n return (key, uint256(value));\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n */\n function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {\n (bool success, bytes32 value) = tryGet(map._inner, key);\n return (success, uint256(value));\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {\n return uint256(get(map._inner, key));\n }\n\n /**\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryGet}.\n */\n function get(\n Bytes32ToUintMap storage map,\n bytes32 key,\n string memory errorMessage\n ) internal view returns (uint256) {\n return uint256(get(map._inner, key, errorMessage));\n }\n\n /**\n * @dev Return the an array containing all the keys\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) {\n bytes32[] memory store = keys(map._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface ISwapRouter is IUniswapV3SwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.6.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n\nlibrary TransferHelper {\n /// @notice Transfers tokens from the targeted address to the given destination\n /// @notice Errors with 'STF' if transfer fails\n /// @param token The contract address of the token to be transferred\n /// @param from The originating address from which the tokens will be transferred\n /// @param to The destination address of the transfer\n /// @param value The amount to be transferred\n function safeTransferFrom(\n address token,\n address from,\n address to,\n uint256 value\n ) internal {\n (bool success, bytes memory data) =\n token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));\n require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');\n }\n\n /// @notice Transfers tokens from msg.sender to a recipient\n /// @dev Errors with ST if transfer fails\n /// @param token The contract address of the token which will be transferred\n /// @param to The recipient of the transfer\n /// @param value The value of the transfer\n function safeTransfer(\n address token,\n address to,\n uint256 value\n ) internal {\n (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));\n require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');\n }\n\n /// @notice Approves the stipulated contract to spend the given allowance in the given token\n /// @dev Errors with 'SA' if transfer fails\n /// @param token The contract address of the token to be approved\n /// @param to The target of the approval\n /// @param value The amount of the given token the target will be allowed to spend\n function safeApprove(\n address token,\n address to,\n uint256 value\n ) internal {\n (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));\n require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');\n }\n\n /// @notice Transfers ETH to the recipient address\n /// @dev Fails with `STE`\n /// @param to The destination of the transfer\n /// @param value The value to be transferred\n function safeTransferETH(address to, uint256 value) internal {\n (bool success, ) = to.call{value: value}(new bytes(0));\n require(success, 'STE');\n }\n}\n" + }, + "contracts/facets/AccountFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../interfaces/IAccount.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../utils/AddressUtils.sol\";\nimport \"../process/AssetsProcess.sol\";\nimport \"../process/AccountProcess.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract AccountFacet is IAccount {\n using SafeERC20 for IERC20;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n using Config for Config.Props;\n\n function deposit(address token, uint256 amount) external payable override {\n if (amount == 0) {\n revert Errors.AmountZeroNotAllowed();\n }\n bool isNativeToken = token == address(0);\n if (isNativeToken && msg.value != amount) {\n revert Errors.AmountNotMatch(msg.value, amount);\n }\n address account = msg.sender;\n AssetsProcess.deposit(\n AssetsProcess.DepositParams(\n account,\n isNativeToken ? Config.load().getWrapperToken() : token,\n amount,\n AssetsProcess.DepositFrom.MANUAL,\n isNativeToken\n )\n );\n }\n\n function createWithdrawRequest(address token, uint256 amount) external override {\n AddressUtils.validEmpty(token);\n if (amount == 0) {\n revert Errors.AmountZeroNotAllowed();\n }\n AssetsProcess.createWithdrawRequest(token, amount);\n }\n\n function executeWithdraw(uint256 requestId, OracleProcess.OracleParam[] calldata oracles) external override {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n Withdraw.Request memory request = Withdraw.get(requestId);\n if (request.account == address(0)) {\n revert Errors.WithdrawRequestNotExists();\n }\n OracleProcess.setOraclePrice(oracles);\n AssetsProcess.executeWithdraw(requestId, request);\n OracleProcess.clearOraclePrice();\n }\n\n function cancelWithdraw(uint256 requestId, bytes32 reasonCode) external override {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n Withdraw.Request memory request = Withdraw.get(requestId);\n if (request.account == address(0)) {\n revert Errors.WithdrawRequestNotExists();\n }\n AssetsProcess.cancelWithdraw(requestId, request, reasonCode);\n }\n\n function batchUpdateAccountToken(AssetsProcess.UpdateAccountTokenParams calldata params) external override {\n AddressUtils.validEmpty(params.account);\n AssetsProcess.updateAccountToken(params);\n }\n\n function getAccountInfo(address account) external view override returns (AccountInfo memory) {\n Account.Props storage accountInfo = Account.load(account);\n address[] memory tokens = accountInfo.getTokens();\n Account.TokenBalance[] memory tokenBalances = new Account.TokenBalance[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n tokenBalances[i] = accountInfo.getTokenBalance(tokens[i]);\n }\n bytes32[] memory positions = accountInfo.getAllPosition();\n return AccountInfo(account, tokenBalances, tokens, positions, 0, 0, 0, accountInfo.orderHoldInUsd, 0, 0, 0);\n }\n\n function getAccountInfoWithOracles(\n address account,\n OracleProcess.OracleParam[] calldata oracles\n ) external view returns (AccountInfo memory) {\n Account.Props storage accountInfo = Account.load(account);\n address[] memory tokens = accountInfo.getTokens();\n Account.TokenBalance[] memory tokenBalances = new Account.TokenBalance[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n tokenBalances[i] = accountInfo.getTokenBalance(tokens[i]);\n }\n bytes32[] memory positions = accountInfo.getAllPosition();\n (int256 accountMMR, int256 crossNetValue, uint256 totalMM) = accountInfo.getCrossMMR(oracles);\n return\n AccountInfo(\n account,\n tokenBalances,\n tokens,\n positions,\n accountInfo.getPortfolioNetValue(oracles),\n accountInfo.getTotalUsedValue(oracles),\n accountInfo.getCrossAvailableValue(oracles),\n accountInfo.orderHoldInUsd,\n accountMMR,\n crossNetValue,\n totalMM\n );\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/facets/AutoReduceFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IAutoReduce.sol\";\nimport \"../process/AutoReduceProcess.sol\";\nimport \"../process/GasProcess.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract AutoReduceFacet is IAutoReduce {\n function autoRedeem(\n address stakeToken,\n address[] calldata account,\n address collateral,\n OracleProcess.OracleParam[] calldata oracles\n ) external {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n uint256 startGas = gasleft();\n OracleProcess.setOraclePrice(oracles);\n AutoReduceProcess.autoRedeem(stakeToken, account, collateral);\n OracleProcess.clearOraclePrice();\n GasProcess.addLossExecutionFee(startGas);\n \n }\n\n function autoReduce(\n bytes32[] calldata positionKeys,\n OracleProcess.OracleParam[] calldata oracles\n ) external override {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n uint256 startGas = gasleft();\n OracleProcess.setOraclePrice(oracles);\n AutoReduceProcess.autoReducePositions(positionKeys);\n OracleProcess.clearOraclePrice();\n GasProcess.addLossExecutionFee(startGas);\n }\n}\n" + }, + "contracts/facets/ConfigFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/ConfigProcess.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract ConfigFacet {\n\n function getConfig() external view returns (IConfig.CommonConfigParams memory config) {\n return ConfigProcess.getConfig();\n }\n\n function getPoolConfig(address stakeToken) public view returns (IConfig.LpPoolConfigParams memory config) {\n return ConfigProcess.getPoolConfig(stakeToken);\n }\n\n function getUsdPoolConfig() public view returns (IConfig.UsdPoolConfigParams memory config) {\n return ConfigProcess.getUsdPoolConfig();\n }\n\n function getSymbolConfig(bytes32 code) public view returns (IConfig.SymbolConfigParams memory config) {\n return ConfigProcess.getSymbolConfig(code);\n }\n\n function setConfig(IConfig.CommonConfigParams calldata params) external {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_CONFIG);\n ConfigProcess.setConfig(params);\n }\n\n function setPoolConfig(IConfig.LpPoolConfigParams calldata params) external {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_CONFIG);\n ConfigProcess.setPoolConfig(params);\n }\n\n function setUsdPoolConfig(IConfig.UsdPoolConfigParams calldata params) external {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_CONFIG);\n ConfigProcess.setUsdPoolConfig(params);\n }\n\n function setSymbolConfig(IConfig.SymbolConfigParams calldata params) external {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_CONFIG);\n ConfigProcess.setSymbolConfig(params);\n }\n}\n" + }, + "contracts/facets/DiamondCutFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\nimport { IDiamondCut } from \"../interfaces/IDiamondCut.sol\";\nimport { LibDiamond } from \"../storage/LibDiamond.sol\";\n\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\n// The loupe functions are required by the EIP2535 Diamonds standard\n\ncontract DiamondCutFacet is IDiamondCut {\n /// @notice Add/replace/remove any number of functions and optionally execute\n /// a function with delegatecall\n /// @param _diamondCut Contains the facet addresses and function selectors\n /// @param _init The address of the contract or facet to execute _calldata\n /// @param _calldata A function call, including function selector and arguments\n /// _calldata is executed with delegatecall on _init\n function diamondCut(\n FacetCut[] calldata _diamondCut,\n address _init,\n bytes calldata _calldata\n ) external override {\n LibDiamond.enforceIsContractOwner();\n LibDiamond.diamondCut(_diamondCut, _init, _calldata);\n }\n}\n" + }, + "contracts/facets/DiamondLoupeFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\n// The functions in DiamondLoupeFacet MUST be added to a diamond.\n// The EIP-2535 Diamond standard requires these functions.\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { LibDiamond } from \"../storage/LibDiamond.sol\";\nimport { IDiamondLoupe } from \"../interfaces/IDiamondLoupe.sol\";\n\ncontract DiamondLoupeFacet is IDiamondLoupe, IERC165 {\n // Diamond Loupe Functions\n ////////////////////////////////////////////////////////////////////\n /// These functions are expected to be called frequently by tools.\n //\n // struct Facet {\n // address facetAddress;\n // bytes4[] functionSelectors;\n // }\n /// @notice Gets all facets and their selectors.\n /// @return facets_ Facet\n function facets() external override view returns (Facet[] memory facets_) {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n uint256 selectorCount = ds.selectors.length;\n // create an array set to the maximum size possible\n facets_ = new Facet[](selectorCount);\n // create an array for counting the number of selectors for each facet\n uint16[] memory numFacetSelectors = new uint16[](selectorCount);\n // total number of facets\n uint256 numFacets;\n // loop through function selectors\n for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) {\n bytes4 selector = ds.selectors[selectorIndex];\n address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress;\n bool continueLoop = false;\n // find the functionSelectors array for selector and add selector to it\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\n if (facets_[facetIndex].facetAddress == facetAddress_) {\n facets_[facetIndex].functionSelectors[numFacetSelectors[facetIndex]] = selector; \n numFacetSelectors[facetIndex]++;\n continueLoop = true;\n break;\n }\n }\n // if functionSelectors array exists for selector then continue loop\n if (continueLoop) {\n continueLoop = false;\n continue;\n }\n // create a new functionSelectors array for selector\n facets_[numFacets].facetAddress = facetAddress_;\n facets_[numFacets].functionSelectors = new bytes4[](selectorCount);\n facets_[numFacets].functionSelectors[0] = selector;\n numFacetSelectors[numFacets] = 1;\n numFacets++;\n }\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\n uint256 numSelectors = numFacetSelectors[facetIndex];\n bytes4[] memory selectors = facets_[facetIndex].functionSelectors;\n // setting the number of selectors\n assembly {\n mstore(selectors, numSelectors)\n }\n }\n // setting the number of facets\n assembly {\n mstore(facets_, numFacets)\n }\n }\n\n /// @notice Gets all the function selectors supported by a specific facet.\n /// @param _facet The facet address.\n /// @return _facetFunctionSelectors The selectors associated with a facet address.\n function facetFunctionSelectors(address _facet) external override view returns (bytes4[] memory _facetFunctionSelectors) {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n uint256 selectorCount = ds.selectors.length;\n uint256 numSelectors;\n _facetFunctionSelectors = new bytes4[](selectorCount);\n // loop through function selectors\n for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) {\n bytes4 selector = ds.selectors[selectorIndex];\n address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress;\n if (_facet == facetAddress_) {\n _facetFunctionSelectors[numSelectors] = selector;\n numSelectors++;\n }\n }\n // Set the number of selectors in the array\n assembly {\n mstore(_facetFunctionSelectors, numSelectors)\n }\n }\n\n /// @notice Get all the facet addresses used by a diamond.\n /// @return facetAddresses_\n function facetAddresses() external override view returns (address[] memory facetAddresses_) {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n uint256 selectorCount = ds.selectors.length;\n // create an array set to the maximum size possible\n facetAddresses_ = new address[](selectorCount);\n uint256 numFacets;\n // loop through function selectors\n for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) {\n bytes4 selector = ds.selectors[selectorIndex];\n address facetAddress_ = ds.facetAddressAndSelectorPosition[selector].facetAddress;\n bool continueLoop = false;\n // see if we have collected the address already and break out of loop if we have\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\n if (facetAddress_ == facetAddresses_[facetIndex]) {\n continueLoop = true;\n break;\n }\n }\n // continue loop if we already have the address\n if (continueLoop) {\n continueLoop = false;\n continue;\n }\n // include address\n facetAddresses_[numFacets] = facetAddress_;\n numFacets++;\n }\n // Set the number of facet addresses in the array\n assembly {\n mstore(facetAddresses_, numFacets)\n }\n }\n\n /// @notice Gets the facet address that supports the given selector.\n /// @dev If facet is not found return address(0).\n /// @param _functionSelector The function selector.\n /// @return facetAddress_ The facet address.\n function facetAddress(bytes4 _functionSelector) external override view returns (address facetAddress_) {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n facetAddress_ = ds.facetAddressAndSelectorPosition[_functionSelector].facetAddress;\n }\n\n // This implements ERC-165.\n function supportsInterface(bytes4 _interfaceId) external override view returns (bool) {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n return ds.supportedInterfaces[_interfaceId];\n }\n}\n" + }, + "contracts/facets/FeeFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IFee.sol\";\nimport \"../storage/RoleAccessControl.sol\";\nimport \"../process/FeeQueryProcess.sol\";\nimport \"../process/FeeRewardsProcess.sol\";\nimport \"../process/ClaimRewardsProcess.sol\";\nimport \"../process/OracleProcess.sol\";\nimport \"../process/GasProcess.sol\";\n\ncontract FeeFacet is IFee {\n function distributeFeeRewards(uint256 interval, OracleProcess.OracleParam[] calldata oracles) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n OracleProcess.setOraclePrice(oracles);\n FeeRewardsProcess.distributeFeeRewards(interval);\n OracleProcess.clearOraclePrice();\n GasProcess.addLossExecutionFee(startGas);\n }\n\n function createClaimRewards(address claimUsdToken, uint256 executionFee) external payable override {\n ClaimRewardsProcess.createClaimRewards(msg.sender, claimUsdToken, executionFee);\n }\n\n function executeClaimRewards(uint256 requestId, OracleProcess.OracleParam[] calldata oracles) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n ClaimRewards.Request memory request = ClaimRewards.get(requestId);\n if (request.account == address(0)) {\n revert Errors.ClaimRewardsRequestNotExists();\n }\n OracleProcess.setOraclePrice(oracles);\n ClaimRewardsProcess.claimRewards(requestId, request);\n OracleProcess.clearOraclePrice();\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n IVault(address(this)).getPortfolioVaultAddress(),\n request.executionFee,\n startGas,\n msg.sender,\n request.account\n )\n );\n }\n\n function cancelClaimRewards(uint256 requestId, bytes32 reasonCode) external {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n ClaimRewards.Request memory request = ClaimRewards.get(requestId);\n if (request.account == address(0)) {\n revert Errors.ClaimRewardsRequestNotExists();\n }\n ClaimRewardsProcess.cancelClaimRewards(requestId, request, reasonCode);\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n IVault(address(this)).getPortfolioVaultAddress(),\n request.executionFee,\n startGas,\n msg.sender,\n request.account\n )\n );\n }\n\n function getPoolTokenFee(address stakeToken, address token) external view override returns (uint256) {\n return FeeQueryProcess.getPoolTokenFeeAmount(stakeToken, token);\n }\n\n function getCumulativeRewardsPerStakeToken(address stakeToken) external view override returns (uint256) {\n return FeeQueryProcess.getCumulativeRewardsPerStakeToken(stakeToken);\n }\n\n function getMarketTokenFee(bytes32 symbol, address token) external view override returns (uint256) {\n return FeeQueryProcess.getMarketTokenFeeAmount(symbol, token);\n }\n\n function getStakingTokenFee(address stakeToken, address token) external view override returns (uint256) {\n return FeeQueryProcess.getStakingTokenFee(stakeToken, token);\n }\n\n function getDaoTokenFee(address stakeToken, address token) external view override returns (uint256) {\n return FeeQueryProcess.getDaoTokenFee(stakeToken, token);\n }\n\n function getAccountFeeRewards() external view override returns (AccountFeeRewards[] memory) {\n return FeeQueryProcess.getAccountFeeRewards(msg.sender);\n }\n\n function getAccountsFeeRewards(\n address[] calldata accounts\n ) external view override returns (AccountFeeRewards[][] memory) {\n AccountFeeRewards[][] memory result = new AccountFeeRewards[][](accounts.length);\n for (uint256 i; i < accounts.length; i++) {\n result[i] = FeeQueryProcess.getAccountFeeRewards(accounts[i]);\n }\n return result;\n }\n\n}\n" + }, + "contracts/facets/LiquidationFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/ILiquidation.sol\";\nimport \"../process/LiquidationProcess.sol\";\nimport \"../process/GasProcess.sol\";\nimport \"../storage/InsuranceFund.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract LiquidationFacet is ILiquidation {\n using InsuranceFund for InsuranceFund.Props;\n\n function liquidationPosition(bytes32 positionKey, OracleProcess.OracleParam[] calldata oracles) external override {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n uint256 startGas = gasleft();\n OracleProcess.setOraclePrice(oracles);\n LiquidationProcess.liquidationIsolatePosition(positionKey);\n OracleProcess.clearOraclePrice();\n GasProcess.addLossExecutionFee(startGas);\n }\n\n function liquidationAccount(address account, OracleProcess.OracleParam[] calldata oracles) external override {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n uint256 startGas = gasleft();\n OracleProcess.setOraclePrice(oracles);\n LiquidationProcess.liquidationCrossPositions(account);\n OracleProcess.clearOraclePrice();\n GasProcess.addLossExecutionFee(startGas);\n }\n\n function getInsuranceFunds(address stakeToken, address token) external view override returns (uint256) {\n return InsuranceFund.load(stakeToken).getTokenFee(token);\n }\n\n function getAllCleanInfos() external view override returns (LiabilityClean.LiabilityCleanInfo[] memory) {\n return LiabilityClean.getAllCleanInfo();\n }\n}\n" + }, + "contracts/facets/MarketFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../interfaces/IMarket.sol\";\nimport \"../process/MarketQueryProcess.sol\";\nimport \"../process/ConfigProcess.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../storage/UuidCreator.sol\";\n\ncontract MarketFacet is IMarket {\n function getAllSymbols() external view override returns (SymbolInfo[] memory) {\n bytes32[] memory symbols = CommonData.getAllSymbols();\n SymbolInfo[] memory infos = new SymbolInfo[](symbols.length);\n for (uint256 i; i < symbols.length; i++) {\n infos[i] = _getSingleSymbol(symbols[i]);\n }\n return infos;\n }\n\n function getSymbol(bytes32 code) external view override returns (SymbolInfo memory params) {\n return _getSingleSymbol(code);\n }\n\n function getStakeUsdToken() external view override returns (address) {\n return CommonData.getStakeUsdToken();\n }\n\n function getMarketInfo(\n bytes32 code,\n OracleProcess.OracleParam[] calldata oracles\n ) external view override returns (MarketInfo memory) {\n return MarketQueryProcess.getMarketInfo(code, oracles);\n }\n\n function getLastUuid(bytes32 key) external view override returns (uint256) {\n return UuidCreator.getId(key);\n }\n\n function _getSingleSymbol(bytes32 code) internal view returns (SymbolInfo memory params) {\n Symbol.Props storage props = Symbol.load(code);\n if (props.stakeToken != address(0)) {\n params.code = props.code;\n params.status = props.status;\n params.stakeToken = props.stakeToken;\n params.indexToken = props.indexToken;\n params.baseToken = props.baseToken;\n params.config = ConfigProcess.getSymbolConfig(code).config;\n }\n }\n}\n" + }, + "contracts/facets/MarketManagerFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/IMarketManager.sol\";\nimport \"../process/MarketFactoryProcess.sol\";\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/RoleAccessControl.sol\";\nimport \"../utils/AddressUtils.sol\";\nimport \"../utils/TypeUtils.sol\";\nimport \"hardhat/console.sol\";\n\ncontract MarketManagerFacet is IMarketManager, ReentrancyGuard {\n function createMarket(MarketFactoryProcess.CreateMarketParams calldata params) external override nonReentrant {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_CONFIG);\n TypeUtils.validBytes32Empty(params.code);\n TypeUtils.validStringEmpty(params.stakeTokenName);\n AddressUtils.validEmpty(params.indexToken);\n AddressUtils.validEmpty(params.baseToken);\n MarketFactoryProcess.createMarket(params);\n }\n\n function createStakeUsdPool(string calldata stakeTokenName) external override nonReentrant returns (address) {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_CONFIG);\n TypeUtils.validStringEmpty(stakeTokenName);\n return MarketFactoryProcess.createStakeUsdPool(stakeTokenName);\n }\n}\n" + }, + "contracts/facets/OracleFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IOracle.sol\";\n\ncontract OracleFacet is IOracle {\n function getLatestUsdPrice(address token, bool min) external view returns (int256) {\n return OracleProcess.getLatestUsdPrice(token, min);\n }\n\n function setOraclePrices(OracleProcess.OracleParam[] calldata params) external {\n OracleProcess.setOraclePrice(params);\n }\n}\n" + }, + "contracts/facets/OrderFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"../interfaces/IOrder.sol\";\nimport \"../interfaces/IAccount.sol\";\nimport \"../process/AssetsProcess.sol\";\nimport \"../process/OrderProcess.sol\";\nimport \"../process/CancelOrderProcess.sol\";\nimport \"../process/GasProcess.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/Order.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract OrderFacet is IOrder, ReentrancyGuard {\n using SafeCast for uint256;\n using Account for Account.Props;\n using Order for Order.Props;\n using Config for Config.Props;\n\n function createOrderRequest(PlaceOrderParams calldata params) external payable override nonReentrant {\n address account = msg.sender;\n if (params.posSide == Order.PositionSide.INCREASE && !params.isCrossMargin) {\n require(!params.isNativeToken || msg.value == params.orderMargin, \"Deposit native token amount error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n account,\n params.marginToken,\n params.orderMargin,\n AssetsProcess.DepositFrom.ORDER,\n params.isNativeToken\n )\n );\n }\n Account.Props storage accountProps = Account.loadOrCreate(account);\n OrderProcess.createOrderRequest(accountProps, params, true);\n }\n\n function batchCreateOrderRequest(PlaceOrderParams[] calldata params) external payable {\n address account = msg.sender;\n Account.Props storage accountProps = Account.loadOrCreate(account);\n uint256 totalExecutionFee;\n Config.ChainConfig memory chainConfig = Config.getChainConfig();\n for (uint256 i; i < params.length; i++) {\n if (params[i].posSide == Order.PositionSide.INCREASE) {\n revert Errors.OnlyDecreaseOrderSupported();\n }\n GasProcess.validateExecutionFeeLimit(params[i].executionFee, chainConfig.placeDecreaseOrderGasFeeLimit);\n OrderProcess.createOrderRequest(accountProps, params[i], false);\n totalExecutionFee += params[i].executionFee;\n }\n require(msg.value == totalExecutionFee, \"Batch place order with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n accountProps.owner,\n chainConfig.wrapperToken,\n totalExecutionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n }\n\n function executeOrder(uint256 orderId, OracleProcess.OracleParam[] calldata oracles) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n Order.OrderInfo memory order = Order.get(orderId);\n if (order.account == address(0)) {\n revert Errors.OrderNotExists(orderId);\n }\n OracleProcess.setOraclePrice(oracles);\n OrderProcess.executeOrder(orderId, order);\n OracleProcess.clearOraclePrice();\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n order.isExecutionFeeFromTradeVault\n ? IVault(address(this)).getTradeVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n order.executionFee,\n startGas,\n msg.sender,\n order.account\n )\n );\n }\n\n function cancelOrder(uint256 orderId, bytes32 reasonCode) external override {\n uint256 startGas = gasleft();\n Order.OrderInfo memory order = Order.get(orderId);\n if (order.account == address(0)) {\n revert Errors.OrderNotExists(orderId);\n }\n bool isKeeper = RoleAccessControl.hasRole(RoleAccessControl.ROLE_KEEPER);\n if (!isKeeper && order.account != msg.sender) {\n revert Errors.OrderNotExists(orderId);\n }\n\n CancelOrderProcess.cancelOrder(orderId, order, reasonCode);\n \n if (isKeeper) {\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n order.isExecutionFeeFromTradeVault\n ? IVault(address(this)).getTradeVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n order.executionFee,\n startGas,\n msg.sender,\n order.account\n )\n );\n } else {\n VaultProcess.transferOut(\n order.isExecutionFeeFromTradeVault\n ? IVault(address(this)).getTradeVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n Config.getWrapperToken(),\n address(this),\n order.executionFee\n );\n VaultProcess.withdrawEther(order.account, order.executionFee);\n }\n }\n\n receive() external payable {}\n\n function getAccountOrders(address account) external view override returns (AccountOrder[] memory) {\n Account.Props storage accountProps = Account.load(account);\n uint256[] memory orders = accountProps.getOrders();\n AccountOrder[] memory orderList = new AccountOrder[](orders.length);\n Order.Props storage orderStorage = Order.load();\n for (uint256 i; i < orders.length; i++) {\n orderList[i].orderId = orders[i];\n orderList[i].orderInfo = orderStorage.get(orders[i]);\n }\n return orderList;\n }\n}\n" + }, + "contracts/facets/OwnershipFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport { LibDiamond } from \"../storage/LibDiamond.sol\";\n\ncontract OwnershipFacet {\n function transferOwnership(address _newOwner) external {\n LibDiamond.enforceIsContractOwner();\n LibDiamond.setContractOwner(_newOwner);\n }\n\n function owner() external view returns (address owner_) {\n owner_ = LibDiamond.contractOwner();\n }\n}\n" + }, + "contracts/facets/PoolFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/IPool.sol\";\nimport \"../process/LpPoolQueryProcess.sol\";\n\ncontract PoolFacet is IPool, ReentrancyGuard {\n\n function getUsdPool() external view override returns (UsdPoolInfo memory) {\n return LpPoolQueryProcess.getUsdPool();\n }\n\n function getUsdPoolWithOracle(\n OracleProcess.OracleParam[] calldata oracles\n ) external view override returns (UsdPoolInfo memory) {\n return LpPoolQueryProcess.getUsdPoolWithOracle(oracles);\n }\n\n function getPool(address stakeToken) external view override returns (PoolInfo memory) {\n OracleProcess.OracleParam[] memory oracles;\n return LpPoolQueryProcess.getPool(stakeToken, oracles);\n }\n\n function getPoolWithOracle(\n address stakeToken,\n OracleProcess.OracleParam[] calldata oracles\n ) external view override returns (PoolInfo memory) {\n return LpPoolQueryProcess.getPool(stakeToken, oracles);\n }\n\n function getAllPools(\n OracleProcess.OracleParam[] calldata oracles\n ) external view override returns (PoolInfo[] memory) {\n return LpPoolQueryProcess.getAllPools(oracles);\n }\n\n}\n" + }, + "contracts/facets/PositionFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/IPosition.sol\";\nimport \"../interfaces/IAccount.sol\";\nimport \"../process/AssetsProcess.sol\";\nimport \"../process/DecreasePositionProcess.sol\";\nimport \"../process/PositionMarginProcess.sol\";\nimport \"../process/GasProcess.sol\";\nimport \"../process/ConfigProcess.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../storage/RoleAccessControl.sol\";\nimport \"../utils/ChainUtils.sol\";\n\ncontract PositionFacet is IPosition, ReentrancyGuard {\n using Account for Account.Props;\n using PositionQueryProcess for Position.Props;\n using DecreasePositionProcess for Position.Props;\n using Position for Position.Props;\n\n bytes32 constant AUTO_REDUCE_ID_KEY = keccak256(\"AUTO_REDUCE_ID_KEY\");\n\n function createUpdatePositionMarginRequest(UpdatePositionMarginParams calldata params) external payable override {\n if (params.updateMarginAmount == 0) {\n revert Errors.AmountZeroNotAllowed();\n }\n address account = msg.sender;\n Account.Props storage accountProps = Account.load(account);\n if (!accountProps.hasPosition(params.positionKey)) {\n revert Errors.PositionNotExists();\n }\n Position.Props storage position = Position.load(params.positionKey);\n if (position.isCrossMargin) {\n revert Errors.OnlyIsolateSupported();\n }\n if (params.isAdd) {\n require(!params.isNativeToken || msg.value == params.updateMarginAmount, \"Deposit eth amount error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n account,\n params.isNativeToken ? Config.getWrapperToken() : params.marginToken,\n params.updateMarginAmount,\n AssetsProcess.DepositFrom.ORDER,\n params.isNativeToken\n )\n );\n }\n\n (uint256 updateMarginAmount, bool isExecutionFeeFromTradeVault) = _validateUpdateMarginExecutionFee(\n accountProps,\n params\n );\n\n PositionMarginProcess.createUpdatePositionMarginRequest(\n account,\n params,\n updateMarginAmount,\n isExecutionFeeFromTradeVault\n );\n }\n\n function executeUpdatePositionMarginRequest(\n uint256 requestId,\n OracleProcess.OracleParam[] calldata oracles\n ) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n UpdatePositionMargin.Request memory request = UpdatePositionMargin.get(requestId);\n if (request.account == address(0)) {\n revert Errors.UpdateLeverageRequestNotExists();\n }\n OracleProcess.setOraclePrice(oracles);\n PositionMarginProcess.updatePositionMargin(requestId, request);\n OracleProcess.clearOraclePrice();\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n request.isExecutionFeeFromTradeVault\n ? IVault(address(this)).getTradeVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n request.executionFee,\n startGas,\n msg.sender,\n request.account\n )\n );\n }\n\n function cancelUpdatePositionMarginRequest(uint256 requestId, bytes32 reasonCode) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n UpdatePositionMargin.Request memory request = UpdatePositionMargin.get(requestId);\n if (request.account == address(0)) {\n revert Errors.UpdatePositionMarginRequestNotExists();\n }\n PositionMarginProcess.cancelUpdatePositionMarginRequest(requestId, request, reasonCode);\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n request.isExecutionFeeFromTradeVault\n ? IVault(address(this)).getTradeVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n request.executionFee,\n startGas,\n msg.sender,\n request.account\n )\n );\n }\n\n function createUpdateLeverageRequest(UpdateLeverageParams calldata params) external payable override {\n IConfig.SymbolConfigParams memory symbolConfig = ConfigProcess.getSymbolConfig(params.symbol);\n Symbol.Props memory symbolProps = Symbol.load(params.symbol);\n if (symbolProps.code.length == 0) {\n revert Errors.SymbolNotExists();\n }\n if (symbolProps.status != Symbol.Status.OPEN) {\n revert Errors.SymbolStatusInvalid(params.symbol);\n }\n if (params.leverage > symbolConfig.config.maxLeverage || params.leverage < 1 * CalUtils.RATE_PRECISION) {\n revert Errors.LeverageInvalid(params.symbol, params.leverage);\n }\n address account = msg.sender;\n Account.Props storage accountProps = Account.load(account);\n\n if (params.addMarginAmount > 0 && !params.isCrossMargin) {\n require(!params.isNativeToken || msg.value == params.addMarginAmount, \"Deposit eth amount error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n account,\n params.isNativeToken ? Config.getWrapperToken() : params.marginToken,\n params.addMarginAmount,\n AssetsProcess.DepositFrom.ORDER,\n params.isNativeToken\n )\n );\n }\n\n (uint256 addMarginAmount, bool isExecutionFeeFromTradeVault) = _validateUpdateLeverageExecutionFee(\n accountProps,\n params\n );\n\n PositionMarginProcess.createUpdateLeverageRequest(\n account,\n params,\n addMarginAmount,\n isExecutionFeeFromTradeVault\n );\n }\n\n function executeUpdateLeverageRequest(\n uint256 requestId,\n OracleProcess.OracleParam[] calldata oracles\n ) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n UpdateLeverage.Request memory request = UpdateLeverage.get(requestId);\n if (request.account == address(0)) {\n revert Errors.UpdateLeverageRequestNotExists();\n }\n OracleProcess.setOraclePrice(oracles);\n PositionMarginProcess.updatePositionLeverage(requestId, request);\n OracleProcess.clearOraclePrice();\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n request.isExecutionFeeFromTradeVault\n ? IVault(address(this)).getTradeVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n request.executionFee,\n startGas,\n msg.sender,\n request.account\n )\n );\n }\n\n function cancelUpdateLeverageRequest(uint256 requestId, bytes32 reasonCode) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n UpdateLeverage.Request memory request = UpdateLeverage.get(requestId);\n if (request.account == address(0)) {\n revert Errors.UpdateLeverageRequestNotExists();\n }\n PositionMarginProcess.cancelUpdateLeverageRequest(requestId, request, reasonCode);\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n request.isExecutionFeeFromTradeVault\n ? IVault(address(this)).getTradeVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n request.executionFee,\n startGas,\n msg.sender,\n request.account\n )\n );\n }\n\n function autoReducePositions(bytes32[] calldata positionKeys) external override {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n uint256 requestId = UuidCreator.nextId(AUTO_REDUCE_ID_KEY);\n for (uint256 i; i < positionKeys.length; i++) {\n Position.Props storage position = Position.load(positionKeys[i]);\n position.checkExists();\n position.decreasePosition(\n DecreasePositionProcess.DecreasePositionParams(\n requestId,\n position.symbol,\n false,\n position.isCrossMargin,\n position.marginToken,\n position.qty,\n OracleProcess.getLatestUsdUintPrice(position.indexToken, position.isLong)\n )\n );\n }\n GasProcess.addLossExecutionFee(startGas);\n }\n\n function getAllPositions(address account) external view override returns (PositionInfo[] memory) {\n Account.Props storage accountInfo = Account.load(account);\n bytes32[] memory positionKeys = accountInfo.getAllPosition();\n PositionInfo[] memory positions = new PositionInfo[](positionKeys.length);\n for (uint256 i; i < positionKeys.length; i++) {\n Position.Props storage position = Position.load(positionKeys[i]);\n positions[i].position = position;\n // if (!position.isCrossMargin) {\n // positions[i].liquidationPrice = position.getLiquidationPrice();\n // }\n }\n return positions;\n }\n\n function getSinglePosition(\n address account,\n bytes32 symbol,\n address marginToken,\n bool isCrossMargin\n ) external pure override returns (Position.Props memory) {\n return Position.load(account, symbol, marginToken, isCrossMargin);\n }\n\n function _validateUpdateMarginExecutionFee(\n Account.Props storage accountProps,\n UpdatePositionMarginParams calldata params\n ) internal returns (uint256, bool) {\n Config.Props storage config = Config.load();\n GasProcess.validateExecutionFeeLimit(params.executionFee, config.chainConfig.positionUpdateMarginGasFeeLimit);\n if (params.isNativeToken && params.isAdd && params.updateMarginAmount >= params.executionFee) {\n return (params.updateMarginAmount - params.executionFee, true);\n }\n require(msg.value == params.executionFee, \"update margin with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n accountProps.owner,\n config.chainConfig.wrapperToken,\n params.executionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n return (params.updateMarginAmount, false);\n }\n\n function _validateUpdateLeverageExecutionFee(\n Account.Props storage accountProps,\n UpdateLeverageParams calldata params\n ) internal returns (uint256, bool) {\n Config.ChainConfig memory chainConfig = Config.getChainConfig();\n GasProcess.validateExecutionFeeLimit(params.executionFee, chainConfig.positionUpdateLeverageGasFeeLimit);\n if (params.isNativeToken && params.addMarginAmount >= params.executionFee && !params.isCrossMargin) {\n return (params.addMarginAmount - params.executionFee, true);\n }\n require(msg.value == params.executionFee, \"update leverage with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n accountProps.owner,\n chainConfig.wrapperToken,\n params.executionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n return (params.addMarginAmount, false);\n }\n}\n" + }, + "contracts/facets/RebalanceFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IRebalance.sol\";\nimport \"../process/RebalanceProcess.sol\";\nimport \"../process/SwapProcess.sol\";\nimport \"../process/GasProcess.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract RebalanceFacet is IRebalance {\n\n function autoRebalance(OracleProcess.OracleParam[] calldata oracles) external override {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n uint256 startGas = gasleft();\n OracleProcess.setOraclePrice(oracles);\n RebalanceProcess.autoRebalance();\n OracleProcess.clearOraclePrice();\n GasProcess.addLossExecutionFee(startGas);\n }\n\n}\n" + }, + "contracts/facets/RoleAccessControlFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IRoleAccessControl.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract RoleAccessControlFacet is IRoleAccessControl {\n modifier onlyRoleAdmin() {\n if (!RoleAccessControl.hasRole(msg.sender, RoleAccessControl.ROLE_ADMIN)) {\n revert Errors.InvalidRoleAccess(msg.sender, RoleAccessControl.ROLE_ADMIN);\n }\n _;\n }\n\n constructor() {\n }\n\n function hasRole(address account, bytes32 role) external view returns (bool) {\n return RoleAccessControl.hasRole(account, role);\n }\n\n function grantRole(address account, bytes32 role) external onlyRoleAdmin {\n if (!isRoleValid(role)) {\n revert Errors.InvalidRoleName(role);\n } \n RoleAccessControl.grantRole(account, role);\n }\n\n function revokeRole(address account, bytes32 role) external onlyRoleAdmin {\n RoleAccessControl.revokeRole(account, role);\n }\n\n function revokeAllRole(address account) external onlyRoleAdmin {\n RoleAccessControl.revokeAllRole(account);\n }\n\n function isRoleValid(bytes32 role) internal pure returns (bool) {\n return\n role == RoleAccessControl.ROLE_ADMIN ||\n role == RoleAccessControl.ROLE_CONFIG ||\n role == RoleAccessControl.ROLE_KEEPER;\n }\n}\n" + }, + "contracts/facets/StakeFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/IStake.sol\";\nimport \"../interfaces/IAccount.sol\";\nimport \"../process/MintProcess.sol\";\nimport \"../process/RedeemProcess.sol\";\nimport \"../process/AssetsProcess.sol\";\nimport \"../process/GasProcess.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../storage/RoleAccessControl.sol\";\nimport \"../utils/AddressUtils.sol\";\n\ncontract StakeFacet is IStake, ReentrancyGuard {\n using SafeERC20 for IERC20;\n using Config for Config.Props;\n using LpPool for LpPool.Props;\n using Account for Account.Props;\n\n function createMintStakeTokenRequest(MintStakeTokenParams calldata params) external payable override nonReentrant {\n if (params.requestTokenAmount == 0) {\n revert Errors.MintWithAmountZero();\n }\n if (AddressUtils.isEmpty(params.receiver) || AddressUtils.isEmpty(params.stakeToken)) {\n revert Errors.MintWithParamError();\n }\n\n address account = msg.sender;\n address token = params.requestToken;\n if (CommonData.getStakeUsdToken() == params.stakeToken) {\n if (!UsdPool.isSupportStableToken(token)) {\n revert Errors.MintTokenInvalid(params.stakeToken, token);\n }\n } else if (CommonData.isStakeTokenSupport(params.stakeToken)) {\n LpPool.Props storage pool = LpPool.load(params.stakeToken);\n if (\n pool.baseToken != token &&\n (!params.isCollateral || (params.isCollateral && !pool.isStakeCollateralSupport(token)))\n ) {\n revert Errors.MintTokenInvalid(params.stakeToken, token);\n }\n } else {\n revert Errors.StakeTokenInvalid(params.stakeToken);\n }\n\n if (params.walletRequestTokenAmount > 0) {\n require(!params.isNativeToken || msg.value == params.walletRequestTokenAmount, \"Deposit eth amount error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n account,\n params.requestToken,\n params.walletRequestTokenAmount,\n params.isCollateral ? AssetsProcess.DepositFrom.MINT_COLLATERAL : AssetsProcess.DepositFrom.MINT,\n params.isNativeToken\n )\n );\n }\n\n (uint256 walletRequestTokenAmount, bool isExecutionFeeFromLpVault) = MintProcess\n .validateAndDepositMintExecutionFee(account, params);\n if (params.requestTokenAmount < walletRequestTokenAmount) {\n revert Errors.MintWithParamError();\n }\n\n MintProcess.createMintStakeTokenRequest(\n params,\n account,\n token,\n walletRequestTokenAmount,\n isExecutionFeeFromLpVault\n );\n\n }\n\n function executeMintStakeToken(\n uint256 requestId,\n OracleProcess.OracleParam[] calldata oracles\n ) external override nonReentrant {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n Mint.Request memory mintRequest = Mint.get(requestId);\n if (mintRequest.account == address(0)) {\n revert Errors.MintRequestNotExists();\n }\n OracleProcess.setOraclePrice(oracles);\n\n MintProcess.executeMintStakeToken(requestId, mintRequest);\n\n OracleProcess.clearOraclePrice();\n\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n mintRequest.isExecutionFeeFromLpVault\n ? IVault(address(this)).getLpVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n mintRequest.executionFee,\n startGas,\n msg.sender,\n mintRequest.account\n )\n );\n }\n\n function cancelMintStakeToken(uint256 requestId, bytes32 reasonCode) external {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n Mint.Request memory mintRequest = Mint.get(requestId);\n if (mintRequest.account == address(0)) {\n revert Errors.MintRequestNotExists();\n }\n\n MintProcess.cancelMintStakeToken(requestId, mintRequest, reasonCode);\n\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n mintRequest.isExecutionFeeFromLpVault\n ? IVault(address(this)).getLpVaultAddress()\n : IVault(address(this)).getPortfolioVaultAddress(),\n mintRequest.executionFee,\n startGas,\n msg.sender,\n mintRequest.account\n )\n );\n }\n\n function createRedeemStakeTokenRequest(\n RedeemStakeTokenParams calldata params\n ) external payable override nonReentrant {\n require(params.unStakeAmount > 0, \"unStakeAmount == 0\");\n AddressUtils.validEmpty(params.receiver);\n\n address account = msg.sender;\n uint256 stakeTokenAmount = StakeToken(params.stakeToken).balanceOf(account);\n if (stakeTokenAmount == 0) {\n revert Errors.RedeemWithAmountNotEnough(account, params.stakeToken);\n }\n if (stakeTokenAmount < params.unStakeAmount) {\n revert Errors.RedeemWithAmountNotEnough(account, params.stakeToken);\n }\n if (CommonData.getStakeUsdToken() == params.stakeToken) {\n if (!UsdPool.isSupportStableToken(params.redeemToken)) {\n revert Errors.RedeemTokenInvalid(params.stakeToken, params.redeemToken);\n }\n } else if (CommonData.isStakeTokenSupport(params.stakeToken)) {\n LpPool.Props storage pool = LpPool.load(params.stakeToken);\n if (pool.baseToken != params.redeemToken) {\n revert Errors.RedeemTokenInvalid(params.stakeToken, params.redeemToken);\n }\n } else {\n revert Errors.StakeTokenInvalid(params.stakeToken);\n }\n\n RedeemProcess.validateAndDepositRedeemExecutionFee(account, params.executionFee);\n RedeemProcess.createRedeemStakeTokenRequest(params, account, params.unStakeAmount);\n }\n\n function executeRedeemStakeToken(\n uint256 requestId,\n OracleProcess.OracleParam[] calldata oracles\n ) external override nonReentrant {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n OracleProcess.setOraclePrice(oracles);\n Redeem.Request memory request = Redeem.get(requestId);\n if (request.receiver == address(0)) {\n revert Errors.RedeemRequestNotExists();\n }\n RedeemProcess.executeRedeemStakeToken(requestId, request);\n\n OracleProcess.clearOraclePrice();\n\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n IVault(address(this)).getPortfolioVaultAddress(),\n request.executionFee,\n startGas,\n msg.sender,\n request.account\n )\n );\n }\n\n function cancelRedeemStakeToken(uint256 requestId, bytes32 reasonCode) external {\n uint256 startGas = gasleft();\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n Redeem.Request memory redeemRequest = Redeem.get(requestId);\n if (redeemRequest.receiver == address(0)) {\n revert Errors.RedeemRequestNotExists();\n }\n\n RedeemProcess.cancelRedeemStakeToken(requestId, redeemRequest, reasonCode);\n\n GasProcess.processExecutionFee(\n GasProcess.PayExecutionFeeParams(\n IVault(address(this)).getPortfolioVaultAddress(),\n redeemRequest.executionFee,\n startGas,\n msg.sender,\n redeemRequest.account\n )\n );\n }\n}\n" + }, + "contracts/facets/StakingAccountFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IStakingAccount.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../storage/CommonData.sol\";\n\ncontract StakingAccountFacet is IStakingAccount {\n using StakingAccount for StakingAccount.Props;\n\n function getAccountPoolBalance(\n address account,\n address stakeToken\n ) external view override returns (TokenBalance memory) {\n StakingAccount.Props storage stakingAccount = StakingAccount.load(account);\n address[] memory tokens = stakingAccount.getCollateralTokens(stakeToken);\n uint256[] memory amounts = new uint256[](tokens.length);\n uint256[] memory liabilities = new uint256[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n StakingAccount.CollateralData memory data = stakingAccount.getCollateralToken(stakeToken, tokens[i]);\n amounts[i] = data.amount;\n liabilities[i] = data.stakeLiability;\n }\n\n return TokenBalance(stakingAccount.stakeTokenBalances[stakeToken].stakeAmount, tokens, amounts, liabilities);\n }\n\n function getAccountPoolCollateralAmount(\n address account,\n address stakeToken,\n address collateral\n ) external view override returns (uint256) {\n return StakingAccount.load(account).getCollateralToken(stakeToken, collateral).amount;\n }\n\n function getAccountUsdPoolAmount(address account) external view override returns (uint256) {\n return StakingAccount.load(account).stakeUsdAmount;\n }\n}\n" + }, + "contracts/facets/SwapFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../process/SwapProcess.sol\";\nimport \"../process/AssetsProcess.sol\";\nimport \"../storage/RoleAccessControl.sol\";\n\ncontract SwapFacet is ISwap {\n using SafeCast for uint256;\n using Account for Account.Props;\n\n function swapPortfolioToPayLiability(\n address[] calldata accounts,\n address[][] calldata accountTokens\n ) external override {\n RoleAccessControl.checkRole(RoleAccessControl.ROLE_KEEPER);\n for (uint256 i; i < accounts.length; i++) {\n Account.Props storage accountProps = Account.load(accounts[i]);\n accountProps.checkExists();\n for (uint256 j; j < accountTokens[i].length; j++) {\n _swapSingleLiability(accountProps, accountTokens[i][j]);\n }\n }\n }\n\n function _swapSingleLiability(Account.Props storage accountProps, address token) internal returns(SwapResult memory) {\n uint256 liability = accountProps.getTokenBalance(token).liability;\n if (liability <= 0) {\n revert Errors.IgnoreSwapWithAccountLiabilityZero();\n }\n address[] memory tokens = accountProps.getSortedTokensByDiscount();\n uint256[] memory amounts = new uint256[](tokens.length);\n uint256[] memory minToAmounts = new uint256[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n amounts[i] = accountProps.getAvailableTokenAmount(tokens[i]);\n }\n address portfolioVaultAddress = IVault(address(this)).getPortfolioVaultAddress();\n return\n _swapUserTokens(\n accountProps.owner,\n SwapParams(\n portfolioVaultAddress,\n tokens,\n amounts,\n minToAmounts,\n token,\n portfolioVaultAddress,\n liability\n )\n );\n }\n\n function _swapUserTokens(address account, SwapParams memory params) internal returns (SwapResult memory) {\n SwapResult memory swapResult = SwapProcess.swap(params);\n AssetsProcess.UpdateAccountTokenParams memory updateAccountParams;\n updateAccountParams.account = account;\n updateAccountParams.tokens = new address[](swapResult.fromTokens.length + 1);\n updateAccountParams.changedTokenAmounts = new int256[](swapResult.fromTokens.length + 1);\n for (uint256 i; i < swapResult.fromTokens.length; i++) {\n updateAccountParams.tokens[i] = swapResult.fromTokens[i];\n updateAccountParams.changedTokenAmounts[i] = -(swapResult.reduceFromAmounts[i].toInt256());\n }\n updateAccountParams.tokens[swapResult.fromTokens.length] = swapResult.toToken;\n updateAccountParams.changedTokenAmounts[swapResult.fromTokens.length] = swapResult.toTokenAmount.toInt256();\n AssetsProcess.updateAccountToken(updateAccountParams);\n return swapResult;\n }\n}\n" + }, + "contracts/facets/VaultFacet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IVault.sol\";\nimport \"../vault/TradeVault.sol\";\nimport \"../vault/LpVault.sol\";\nimport \"../vault/PortfolioVault.sol\";\n\ncontract VaultFacet is IVault {\n TradeVault private immutable tradeVault;\n LpVault private immutable lpVault;\n PortfolioVault private immutable portfolioVault;\n\n constructor(TradeVault _tradeVault, LpVault _lpVault, PortfolioVault _portfolioVault) {\n tradeVault = _tradeVault;\n lpVault = _lpVault;\n portfolioVault = _portfolioVault;\n }\n\n function getTradeVault() external view override returns (TradeVault) {\n return tradeVault;\n }\n\n function getLpVault() external view override returns (LpVault) {\n return lpVault;\n }\n\n function getPortfolioVault() external view override returns (PortfolioVault) {\n return portfolioVault;\n }\n\n function getTradeVaultAddress() external view override returns (address) {\n return address(tradeVault);\n }\n\n function getLpVaultAddress() external view override returns (address) {\n return address(lpVault);\n }\n\n function getPortfolioVaultAddress() external view override returns (address) {\n return address(portfolioVault);\n }\n}\n" + }, + "contracts/interfaces/IAccount.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/AssetsProcess.sol\";\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/Withdraw.sol\";\nimport \"../storage/Account.sol\";\n\ninterface IAccount {\n\n struct AccountInfo {\n address owner;\n Account.TokenBalance[] tokenBalances;\n address[] tokens;\n bytes32[] positions;\n uint256 portfolioNetValue;\n uint256 totalUsedValue;\n int256 availableValue;\n uint256 orderHoldInUsd;\n int256 crossMMR;\n int256 crossNetValue;\n uint256 totalMM;\n }\n\n function deposit(address token, uint256 amount) external payable;\n\n function createWithdrawRequest(address token, uint256 amount) external;\n\n function executeWithdraw(uint256 requestId, OracleProcess.OracleParam[] calldata oracles) external;\n\n function cancelWithdraw(uint256 requestId, bytes32 reasonCode) external;\n \n function batchUpdateAccountToken(AssetsProcess.UpdateAccountTokenParams calldata params) external;\n\n function getAccountInfo(address account) external view returns (AccountInfo memory);\n\n function getAccountInfoWithOracles(address account, OracleProcess.OracleParam[] calldata oracles) external view returns (AccountInfo memory);\n}\n" + }, + "contracts/interfaces/IAutoReduce.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/LiabilityClean.sol\";\n\ninterface IAutoReduce {\n function autoReduce(\n bytes32[] calldata positionKeys,\n OracleProcess.OracleParam[] calldata oracles\n ) external;\n\n function autoRedeem(\n address stakeToken,\n address[] calldata account,\n address collateral,\n OracleProcess.OracleParam[] calldata oracles\n ) external;\n}\n" + }, + "contracts/interfaces/IConfig.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../storage/Config.sol\";\n\ninterface IConfig {\n struct CommonConfigParams {\n address wrapperToken;\n uint256 mintGasFeeLimit;\n uint256 redeemGasFeeLimit;\n uint256 placeIncreaseOrderGasFeeLimit;\n uint256 placeDecreaseOrderGasFeeLimit;\n uint256 positionUpdateMarginGasFeeLimit;\n uint256 positionUpdateLeverageGasFeeLimit;\n uint256 claimRewardsGasFeeLimit;\n address[] tradeTokens;\n Config.TradeTokenConfig[] tradeTokenConfigs;\n uint256 minOrderMarginUSD;\n uint256 availableCollateralRatio;\n uint256 crossLtvLimit;\n uint256 executeOrderMinBlockGap;\n uint256 executeOrderMaxBlockGap;\n uint256 executePositionMarginMinBlockGap;\n uint256 executePositionMarginMaxBlockGap;\n uint256 executeLeverageMinBlockGap;\n uint256 executeLeverageMaxBlockGap;\n uint256 maxMaintenanceMarginRate;\n uint256 fundingFeeBaseRate;\n uint256 tradingFeeStakingRewardsRatio;\n uint256 tradingFeePoolRewardsRatio;\n uint256 tradingFeeUsdPoolRewardsRatio;\n uint256 borrowingFeeStakingRewardsRatio;\n uint256 borrowingFeePoolRewardsRatio;\n uint256 autoReduceProfitFactor;\n uint256 autoReduceLiquidityFactor;\n uint256 swapSlipperTokenFactor;\n uint256 minPrecisionMultiple;\n uint256 stakeCollateralProtectFactor;\n uint256 stakeCollateralFactor;\n uint256 mintFeeStakingRewardsRatio;\n uint256 mintFeePoolRewardsRatio;\n uint256 redeemFeeStakingRewardsRatio;\n uint256 redeemFeePoolRewardsRatio;\n address uniswapRouter;\n uint256 poolRewardsIntervalLimit;\n }\n\n struct LpPoolConfigParams {\n address stakeToken;\n uint256 baseInterestRate;\n uint256 poolLiquidityLimit;\n uint256 mintFeeRate;\n uint256 redeemFeeRate;\n uint256 poolPnlRatioLimit;\n uint256 collateralStakingRatioLimit;\n uint256 unsettledBaseTokenRatioLimit;\n uint256 unsettledStableTokenRatioLimit;\n uint256 poolStableTokenRatioLimit;\n uint256 poolStableTokenLossLimit;\n address[] assetTokens;\n address[] supportCollateralTokens;\n Config.StakeCollateralConfig[] collateralTokensConfigs;\n }\n\n struct UsdPoolConfigParams {\n uint256 poolLiquidityLimit;\n uint256 mintFeeRate;\n uint256 redeemFeeRate;\n uint256 unsettledRatioLimit;\n address[] supportStableTokens;\n uint256[] stableTokensBorrowingInterestRate;\n uint256[] stableTokensRatioLimit;\n }\n\n struct SymbolConfigParams {\n bytes32 symbol;\n Config.SymbolConfig config;\n }\n}\n" + }, + "contracts/interfaces/IDiamond.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\ninterface IDiamond {\n enum FacetCutAction {Add, Replace, Remove}\n // Add=0, Replace=1, Remove=2\n\n struct FacetCut {\n address facetAddress;\n FacetCutAction action;\n bytes4[] functionSelectors;\n }\n\n event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\n}" + }, + "contracts/interfaces/IDiamondCut.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\nimport { IDiamond } from \"./IDiamond.sol\";\n\ninterface IDiamondCut is IDiamond { \n\n /// @notice Add/replace/remove any number of functions and optionally execute\n /// a function with delegatecall\n /// @param _diamondCut Contains the facet addresses and function selectors\n /// @param _init The address of the contract or facet to execute _calldata\n /// @param _calldata A function call, including function selector and arguments\n /// _calldata is executed with delegatecall on _init\n function diamondCut(\n FacetCut[] calldata _diamondCut,\n address _init,\n bytes calldata _calldata\n ) external; \n}\n" + }, + "contracts/interfaces/IDiamondLoupe.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\n// A loupe is a small magnifying glass used to look at diamonds.\n// These functions look at diamonds\ninterface IDiamondLoupe {\n /// These functions are expected to be called frequently\n /// by tools.\n\n struct Facet {\n address facetAddress;\n bytes4[] functionSelectors;\n }\n\n /// @notice Gets all facet addresses and their four byte function selectors.\n /// @return facets_ Facet\n function facets() external view returns (Facet[] memory facets_);\n\n /// @notice Gets all the function selectors supported by a specific facet.\n /// @param _facet The facet address.\n /// @return facetFunctionSelectors_\n function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);\n\n /// @notice Get all the facet addresses used by a diamond.\n /// @return facetAddresses_\n function facetAddresses() external view returns (address[] memory facetAddresses_);\n\n /// @notice Gets the facet that supports the given selector.\n /// @dev If facet is not found return address(0).\n /// @param _functionSelector The function selector.\n /// @return facetAddress_ The facet address.\n function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);\n}\n" + }, + "contracts/interfaces/IFee.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\nimport \"../process/FeeQueryProcess.sol\";\n\ninterface IFee {\n\n struct AccountFeeRewards {\n address stakeToken;\n address token;\n uint256 rewards;\n }\n\n function distributeFeeRewards(uint256 interval, OracleProcess.OracleParam[] calldata oracles) external;\n\n function createClaimRewards(address claimUsdToken, uint256 executionFee) external payable;\n\n function executeClaimRewards(uint256 requestId, OracleProcess.OracleParam[] calldata oracles) external;\n\n function getPoolTokenFee(address stakeToken, address token) external view returns (uint256);\n\n function getCumulativeRewardsPerStakeToken(address stakeToken) external view returns (uint256);\n\n function getMarketTokenFee(bytes32 symbol, address token) external view returns (uint256);\n\n function getStakingTokenFee(address stakeToken, address token) external view returns (uint256);\n\n function getDaoTokenFee(address stakeToken, address token) external view returns (uint256);\n\n function getAccountFeeRewards() external view returns (AccountFeeRewards[] memory);\n\n function getAccountsFeeRewards(address[] calldata accounts) external view returns (AccountFeeRewards[][] memory);\n}\n" + }, + "contracts/interfaces/ILiquidation.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/LiabilityClean.sol\";\n\ninterface ILiquidation {\n function liquidationPosition(bytes32 positionKey, OracleProcess.OracleParam[] calldata oracles) external;\n\n function liquidationAccount(address account, OracleProcess.OracleParam[] calldata oracles) external;\n\n function getInsuranceFunds(address stakeToken, address token) external view returns (uint256);\n\n function getAllCleanInfos() external view returns (LiabilityClean.LiabilityCleanInfo[] memory);\n}\n" + }, + "contracts/interfaces/IMarket.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/MarketQueryProcess.sol\";\nimport \"../interfaces/IConfig.sol\";\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/Market.sol\";\n\ninterface IMarket {\n\n struct SymbolInfo {\n bytes32 code;\n Symbol.Status status;\n address stakeToken;\n address indexToken;\n address baseToken;\n Config.SymbolConfig config;\n }\n\n struct MarketInfo {\n Symbol.Props symbolInfo;\n uint256 longPositionInterest;\n uint256 longPositionEntryPrice;\n uint256 totalShortPositionInterest;\n Market.MarketPosition[] shortPositions;\n uint256 availableLiquidity;\n Market.FundingFee fundingFee;\n }\n \n function getAllSymbols() external view returns (SymbolInfo[] memory);\n\n function getSymbol(bytes32 code) external view returns (SymbolInfo memory);\n\n function getStakeUsdToken() external view returns (address);\n\n function getMarketInfo(bytes32 code, OracleProcess.OracleParam[] calldata oracles) external view returns (MarketInfo memory);\n\n function getLastUuid(bytes32 key) external view returns(uint256);\n}\n" + }, + "contracts/interfaces/IMarketManager.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/MarketFactoryProcess.sol\";\nimport \"../process/ConfigProcess.sol\";\nimport \"../interfaces/IConfig.sol\";\n\ninterface IMarketManager {\n function createMarket(MarketFactoryProcess.CreateMarketParams calldata params) external;\n\n function createStakeUsdPool(string calldata stakeTokenName) external returns (address);\n}\n" + }, + "contracts/interfaces/IOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\n\ninterface IOracle {\n \n function getLatestUsdPrice(address token, bool min) external view returns (int256);\n\n function setOraclePrices(OracleProcess.OracleParam[] calldata params) external;\n}\n" + }, + "contracts/interfaces/IOrder.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OrderProcess.sol\";\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/Order.sol\";\n\ninterface IOrder {\n struct PlaceOrderParams {\n bytes32 symbol;\n bool isCrossMargin;\n bool isNativeToken;\n Order.Side orderSide;\n Order.PositionSide posSide;\n Order.Type orderType;\n Order.StopType stopType;\n address marginToken;\n uint256 qty; // decrease only\n uint256 orderMargin; // increase only\n uint256 leverage;\n uint256 triggerPrice;\n uint256 acceptablePrice;\n uint256 executionFee;\n uint256 placeTime;\n }\n\n struct AccountOrder {\n uint256 orderId;\n Order.OrderInfo orderInfo;\n }\n\n function createOrderRequest(PlaceOrderParams calldata params) external payable;\n\n function batchCreateOrderRequest(PlaceOrderParams[] calldata params) external payable;\n\n function executeOrder(uint256 orderId, OracleProcess.OracleParam[] calldata oracles) external;\n\n function cancelOrder(uint256 orderId, bytes32 reasonCode) external;\n\n function getAccountOrders(address account) external view returns (AccountOrder[] memory);\n}\n" + }, + "contracts/interfaces/IPool.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Mint.sol\";\nimport \"../storage/Redeem.sol\";\n\ninterface IPool {\n\n struct PoolInfo {\n address stakeToken;\n string stakeTokenName;\n address baseToken;\n bytes32 symbol;\n MintTokenBalance baseTokenBalance;\n address[] stableTokens;\n MintTokenBalance[] stableTokenBalances;\n uint256 poolValue;\n uint256 availableLiquidity;\n int256 poolPnl;\n uint256 totalSupply;\n LpPool.BorrowingFee borrowingFee;\n uint256 apr;\n }\n\n struct MintTokenBalance {\n uint256 amount;\n uint256 liability;\n uint256 holdAmount;\n int256 unsettledAmount;\n uint256 lossAmount;\n address[] collateralTokens;\n uint256[] collateralAmounts;\n }\n\n struct UsdPoolInfo {\n address[] stableTokens;\n UsdPool.TokenBalance[] stableTokenBalances;\n uint256[] stableTokenMaxWithdraws;\n uint256 poolValue;\n uint256 totalSupply;\n uint256[] tokensAvailableLiquidity;\n UsdPool.BorrowingFee[] borrowingFees;\n uint256 apr;\n }\n\n function getPool(address stakeToken) external view returns (PoolInfo memory);\n\n function getUsdPool() external view returns (UsdPoolInfo memory);\n\n function getPoolWithOracle(address stakeToken, OracleProcess.OracleParam[] calldata oracles) external view returns (PoolInfo memory);\n\n function getUsdPoolWithOracle(OracleProcess.OracleParam[] calldata oracles) external view returns (UsdPoolInfo memory);\n\n function getAllPools(OracleProcess.OracleParam[] calldata oracles) external view returns (PoolInfo[] memory);\n}\n" + }, + "contracts/interfaces/IPosition.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/UpdatePositionMargin.sol\";\nimport \"../storage/UpdateLeverage.sol\";\n\ninterface IPosition {\n\n struct UpdatePositionMarginParams {\n bytes32 positionKey;\n bool isAdd;\n bool isNativeToken;\n address marginToken;\n uint256 updateMarginAmount;\n uint256 executionFee;\n }\n\n struct UpdateLeverageParams {\n bytes32 symbol;\n bool isLong;\n bool isNativeToken;\n bool isCrossMargin;\n uint256 leverage;\n address marginToken;\n uint256 addMarginAmount;\n uint256 executionFee;\n }\n\n struct PositionInfo {\n Position.Props position;\n uint256 liquidationPrice;\n }\n\n function createUpdatePositionMarginRequest(UpdatePositionMarginParams calldata params) external payable;\n\n function executeUpdatePositionMarginRequest(\n uint256 requestId,\n OracleProcess.OracleParam[] calldata oracles\n ) external;\n\n function cancelUpdatePositionMarginRequest(uint256 orderId, bytes32 reasonCode) external;\n\n function createUpdateLeverageRequest(UpdateLeverageParams calldata params) external payable;\n\n function executeUpdateLeverageRequest(uint256 requestId, OracleProcess.OracleParam[] calldata oracles) external;\n\n function cancelUpdateLeverageRequest(uint256 orderId, bytes32 reasonCode) external;\n\n function autoReducePositions(bytes32[] calldata positionKeys) external;\n\n function getAllPositions(address account) external view returns (PositionInfo[] memory);\n\n function getSinglePosition(\n address account,\n bytes32 symbol,\n address marginToken,\n bool isCrossMargin\n ) external pure returns (Position.Props memory);\n}\n" + }, + "contracts/interfaces/IRebalance.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\n\ninterface IRebalance {\n struct RebalancePortfolioParams {\n address token;\n bool isBaseToken;\n address[] stakeTokens;\n }\n\n struct RebalancePortfolioToPoolParams {\n address token;\n bool isBaseToken;\n uint256 rebalanceToLimitAmount;\n address[] stakeTokens;\n address[] autoSwapUsers;\n }\n\n struct TransferTokenParams {\n address stakeToken;\n address[] tokens;\n uint256[] transferAmounts;\n }\n\n struct RebalancePoolStableTokenParams {\n address stakeToken;\n bool swapToBase;\n address[] stableTokens;\n int256[] changedStableAmount;\n int256[] changedStableLossAmount;\n uint256[] transferToBaseTokenAmount;\n uint256[] transferToStableTokenAmount;\n uint256[] usdSettleAmount;\n uint256[] usdAddAmount;\n }\n\n function autoRebalance(OracleProcess.OracleParam[] calldata oracles) external;\n\n // function rebalancePortfolio(RebalancePortfolioParams[] calldata params) external;\n\n // function rebalancePortfolioToPool(RebalancePortfolioToPoolParams calldata params) external;\n\n // function transferUnsettleToken(TransferTokenParams[] calldata params) external;\n\n // function rebalancePoolStableTokens(RebalancePoolStableTokenParams[] calldata params) external;\n}\n" + }, + "contracts/interfaces/IRoleAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface IRoleAccessControl {\n\n function hasRole(address account, bytes32 role) external view returns(bool);\n\n function grantRole(address account, bytes32 role) external;\n\n function revokeRole(address account, bytes32 role) external;\n\n function revokeAllRole(address account) external;\n\n}" + }, + "contracts/interfaces/IStake.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/Mint.sol\";\nimport \"../storage/Redeem.sol\";\n\ninterface IStake {\n\n struct MintStakeTokenParams {\n address receiver;\n address stakeToken;\n address requestToken;\n uint256 requestTokenAmount;\n uint256 walletRequestTokenAmount;\n uint256 minStakeAmount;\n uint256 executionFee;\n bool isCollateral;\n bool isNativeToken;\n }\n\n struct RedeemStakeTokenParams {\n address receiver;\n address stakeToken;\n address redeemToken;\n uint256 unStakeAmount;\n uint256 minRedeemAmount;\n uint256 executionFee;\n }\n\n function createMintStakeTokenRequest(MintStakeTokenParams calldata params) external payable;\n\n function executeMintStakeToken(uint256 requestId, OracleProcess.OracleParam[] calldata oracles) external;\n\n function cancelMintStakeToken(uint256 requestId, bytes32 reasonCode) external;\n\n function createRedeemStakeTokenRequest(RedeemStakeTokenParams calldata params) external payable;\n\n function executeRedeemStakeToken(uint256 requestId, OracleProcess.OracleParam[] calldata oracles) external;\n\n function cancelRedeemStakeToken(uint256 requestId, bytes32 reasonCode) external;\n\n}\n" + }, + "contracts/interfaces/IStakingAccount.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface IStakingAccount {\n struct TokenBalance {\n uint256 stakeAmount;\n address[] collateralTokens;\n uint256[] collateralAmounts;\n uint256[] collateralStakeLiability;\n }\n\n function getAccountPoolBalance(address account, address stakeToken) external view returns (TokenBalance memory);\n\n function getAccountPoolCollateralAmount(\n address account,\n address stakeToken,\n address collateral\n ) external view returns (uint256);\n\n function getAccountUsdPoolAmount(address account) external view returns (uint256);\n}\n" + }, + "contracts/interfaces/ISwap.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../process/AccountProcess.sol\";\nimport \"../process/RebalanceProcess.sol\";\nimport \"../process/OracleProcess.sol\";\nimport \"../storage/Withdraw.sol\";\n\ninterface ISwap {\n struct SwapParams {\n address fromTokenAddress;\n address[] fromTokens;\n uint256[] fromAmounts;\n uint256[] minToTokenAmounts;\n address toToken;\n address toTokenAddress;\n uint256 toTokenAmount;\n }\n\n struct SwapSingleParam {\n address fromTokenAddress;\n address fromToken;\n uint256 fromAmount;\n uint256 minToTokenAmount;\n address toToken;\n address toTokenAddress;\n }\n\n struct SwapResult {\n address[] fromTokens;\n uint256[] reduceFromAmounts;\n address toToken;\n uint256 toTokenAmount;\n uint256 expectToTokenAmount;\n }\n\n struct SwapSingleResult {\n address fromToken;\n uint256 reduceFromAmount;\n address toToken;\n uint256 toTokenAmount;\n }\n\n function swapPortfolioToPayLiability(address[] calldata accounts, address[][] calldata accountTokens) external;\n}\n" + }, + "contracts/interfaces/ITest.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface ITest {\n\n \n function test() external pure returns (string memory name);\n\n}\n" + }, + "contracts/interfaces/IVault.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../vault/TradeVault.sol\";\nimport \"../vault/LpVault.sol\";\nimport \"../vault/PortfolioVault.sol\";\n\ninterface IVault {\n\n function getTradeVault() external view returns (TradeVault);\n\n function getLpVault() external view returns (LpVault);\n\n function getPortfolioVault() external view returns (PortfolioVault);\n\n function getTradeVaultAddress() external view returns (address);\n\n function getLpVaultAddress() external view returns (address);\n\n function getPortfolioVaultAddress() external view returns (address);\n \n}\n" + }, + "contracts/interfaces/IWETH.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface IWETH {\n function deposit() external payable;\n\n function withdraw(uint256 amount) external;\n}\n" + }, + "contracts/mock/MockToken.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"../utils/RoleKeys.sol\";\n\ncontract MockToken is ERC20 {\n uint8 tokenTecimals = 18;\n\n constructor(string memory symbol_, uint8 _decimals) ERC20(\"Mock token\", symbol_) {\n tokenTecimals = _decimals;\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n }\n\n function burn(address account, uint256 amount) external {\n _burn(account, amount);\n }\n\n function decimals() public view override returns (uint8) {\n return tokenTecimals;\n }\n}\n" + }, + "contracts/mock/Multicall3.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n/// @title Multicall3\n/// @notice Aggregate results from multiple function calls\n/// @dev Multicall & Multicall2 backwards-compatible\n/// @dev Aggregate methods are marked `payable` to save 24 gas per call\n/// @author Michael Elliot \n/// @author Joshua Levine \n/// @author Nick Johnson \n/// @author Andreas Bigger \n/// @author Matt Solomon \ncontract Multicall3 {\n struct Call {\n address target;\n bytes callData;\n }\n\n struct Call3 {\n address target;\n bool allowFailure;\n bytes callData;\n }\n\n struct Call3Value {\n address target;\n bool allowFailure;\n uint256 value;\n bytes callData;\n }\n\n struct Result {\n bool success;\n bytes returnData;\n }\n\n /// @notice Backwards-compatible call aggregation with Multicall\n /// @param calls An array of Call structs\n /// @return blockNumber The block number where the calls were executed\n /// @return returnData An array of bytes containing the responses\n function aggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData) {\n blockNumber = block.number;\n uint256 length = calls.length;\n returnData = new bytes[](length);\n Call calldata call;\n for (uint256 i; i < length; ) {\n bool success;\n call = calls[i];\n (success, returnData[i]) = call.target.call(call.callData);\n require(success, \"Multicall3: call failed\");\n unchecked {\n ++i;\n }\n }\n }\n\n /// @notice Backwards-compatible with Multicall2\n /// @notice Aggregate calls without requiring success\n /// @param requireSuccess If true, require all calls to succeed\n /// @param calls An array of Call structs\n /// @return returnData An array of Result structs\n function tryAggregate(\n bool requireSuccess,\n Call[] calldata calls\n ) public payable returns (Result[] memory returnData) {\n uint256 length = calls.length;\n returnData = new Result[](length);\n Call calldata call;\n for (uint256 i; i < length; ) {\n Result memory result = returnData[i];\n call = calls[i];\n (result.success, result.returnData) = call.target.call(call.callData);\n if (requireSuccess) require(result.success, \"Multicall3: call failed\");\n unchecked {\n ++i;\n }\n }\n }\n\n /// @notice Backwards-compatible with Multicall2\n /// @notice Aggregate calls and allow failures using tryAggregate\n /// @param calls An array of Call structs\n /// @return blockNumber The block number where the calls were executed\n /// @return blockHash The hash of the block where the calls were executed\n /// @return returnData An array of Result structs\n function tryBlockAndAggregate(\n bool requireSuccess,\n Call[] calldata calls\n ) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) {\n blockNumber = block.number;\n blockHash = blockhash(block.number);\n returnData = tryAggregate(requireSuccess, calls);\n }\n\n /// @notice Backwards-compatible with Multicall2\n /// @notice Aggregate calls and allow failures using tryAggregate\n /// @param calls An array of Call structs\n /// @return blockNumber The block number where the calls were executed\n /// @return blockHash The hash of the block where the calls were executed\n /// @return returnData An array of Result structs\n function blockAndAggregate(\n Call[] calldata calls\n ) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) {\n (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls);\n }\n\n /// @notice Aggregate calls, ensuring each returns success if required\n /// @param calls An array of Call3 structs\n /// @return returnData An array of Result structs\n function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData) {\n uint256 length = calls.length;\n returnData = new Result[](length);\n Call3 calldata calli;\n for (uint256 i; i < length; ) {\n Result memory result = returnData[i];\n calli = calls[i];\n (result.success, result.returnData) = calli.target.call(calli.callData);\n assembly {\n // Revert if the call fails and failure is not allowed\n // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)`\n if iszero(or(calldataload(add(calli, 0x20)), mload(result))) {\n // set \"Error(string)\" signature: bytes32(bytes4(keccak256(\"Error(string)\")))\n mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n // set data offset\n mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)\n // set length of revert string\n mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017)\n // set revert string: bytes32(abi.encodePacked(\"Multicall3: call failed\"))\n mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000)\n revert(0x00, 0x64)\n }\n }\n unchecked {\n ++i;\n }\n }\n }\n\n /// @notice Aggregate calls with a msg value\n /// @notice Reverts if msg.value is less than the sum of the call values\n /// @param calls An array of Call3Value structs\n /// @return returnData An array of Result structs\n function aggregate3Value(Call3Value[] calldata calls) public payable returns (Result[] memory returnData) {\n uint256 valAccumulator;\n uint256 length = calls.length;\n returnData = new Result[](length);\n Call3Value calldata calli;\n for (uint256 i; i < length; ) {\n Result memory result = returnData[i];\n calli = calls[i];\n uint256 val = calli.value;\n // Humanity will be a Type V Kardashev Civilization before this overflows - andreas\n // ~ 10^25 Wei in existence << ~ 10^76 size uint fits in a uint256\n unchecked {\n valAccumulator += val;\n }\n (result.success, result.returnData) = calli.target.call{ value: val }(calli.callData);\n assembly {\n // Revert if the call fails and failure is not allowed\n // `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)`\n if iszero(or(calldataload(add(calli, 0x20)), mload(result))) {\n // set \"Error(string)\" signature: bytes32(bytes4(keccak256(\"Error(string)\")))\n mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n // set data offset\n mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)\n // set length of revert string\n mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017)\n // set revert string: bytes32(abi.encodePacked(\"Multicall3: call failed\"))\n mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000)\n revert(0x00, 0x84)\n }\n }\n unchecked {\n ++i;\n }\n }\n // Finally, make sure the msg.value = SUM(call[0...i].value)\n require(msg.value == valAccumulator, \"Multicall3: value mismatch\");\n }\n\n /// @notice Returns the block hash for the given block number\n /// @param blockNumber The block number\n function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) {\n blockHash = blockhash(blockNumber);\n }\n\n /// @notice Returns the block number\n function getBlockNumber() public view returns (uint256 blockNumber) {\n blockNumber = block.number;\n }\n\n /// @notice Returns the block coinbase\n function getCurrentBlockCoinbase() public view returns (address coinbase) {\n coinbase = block.coinbase;\n }\n\n /// @notice Returns the block prevrandao\n function getCurrentBlockPrevrandao() public view returns (uint256 prevrandao) {\n prevrandao = block.prevrandao;\n }\n\n /// @notice Returns the block gas limit\n function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {\n gaslimit = block.gaslimit;\n }\n\n /// @notice Returns the block timestamp\n function getCurrentBlockTimestamp() public view returns (uint256 timestamp) {\n timestamp = block.timestamp;\n }\n\n /// @notice Returns the (ETH) balance of a given address\n function getEthBalance(address addr) public view returns (uint256 balance) {\n balance = addr.balance;\n }\n\n /// @notice Returns the block hash of the last block\n function getLastBlockHash() public view returns (bytes32 blockHash) {\n unchecked {\n blockHash = blockhash(block.number - 1);\n }\n }\n\n /// @notice Gets the base fee of the given block\n /// @notice Can revert if the BASEFEE opcode is not implemented by the given chain\n function getBasefee() public view returns (uint256 basefee) {\n basefee = block.basefee;\n }\n\n /// @notice Returns the chain id\n function getChainId() public view returns (uint256 chainid) {\n chainid = block.chainid;\n }\n}\n" + }, + "contracts/mock/WETH.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IWETH.sol\";\nimport \"../mock/MockToken.sol\";\nimport \"hardhat/console.sol\";\n\ncontract WETH is MockToken, IWETH {\n error WithdrawFailed(address account, uint256 amount);\n\n constructor() MockToken(\"Mock for WETH\", 18) {}\n\n function deposit() external payable override {\n _mint(msg.sender, msg.value);\n }\n\n function withdraw(uint256 amount) external override {\n _burn(msg.sender, amount);\n (bool success, ) = msg.sender.call{ value: amount }(\"\");\n if (!success) {\n revert WithdrawFailed(msg.sender, amount);\n }\n }\n \n}\n" + }, + "contracts/process/AccountProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/Position.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./PositionQueryProcess.sol\";\n\nlibrary AccountProcess {\n using SafeERC20 for IERC20;\n using Account for Account.Props;\n using PositionQueryProcess for Position.Props;\n using Config for Config.Props;\n using Position for Position.Props;\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedMath for int256;\n using SignedSafeMath for int256;\n\n function getCrossMMR(\n Account.Props storage accountProps,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (int256, int256, uint256) {\n uint256 portfolioNetValue = getPortfolioNetValue(accountProps, oracles);\n uint256 totalUsedValue = getTotalUsedValue(accountProps, oracles);\n PositionQueryProcess.PositionStaticsCache memory cache = PositionQueryProcess.getAccountAllCrossPositionValue(\n accountProps,\n oracles\n );\n int256 crossNetValue = portfolioNetValue.toInt256() +\n cache.totalIMUsd.toInt256() +\n cache.totalPnl -\n totalUsedValue.toInt256() -\n cache.totalPosFee;\n if (cache.totalMM <= 0) {\n return (0, crossNetValue, cache.totalMM);\n }\n console.log(\"portfolioNetValue\", portfolioNetValue);\n console.log(\"totalIMUsd\", cache.totalIMUsd);\n consoleInt(\"totalPnl\", cache.totalPnl);\n console.log(\"totalUsedValue\", totalUsedValue);\n consoleInt(\"totalPosFee\", cache.totalPosFee);\n console.log(\"totalMM\", cache.totalMM);\n consoleInt(\"crossNetValue\", crossNetValue);\n return (\n crossNetValue <= 0\n ? int256(0)\n : CalUtils.divToPrecision(crossNetValue.toUint256(), cache.totalMM, CalUtils.RATE_PRECISION).toInt256(),\n crossNetValue,\n cache.totalMM\n );\n }\n\n function consoleInt(string memory code, int256 value) internal pure {\n if (value >= 0) {\n console.log(code, value.toUint256());\n } else {\n console.log(\"-\", code, (-value).toUint256());\n }\n }\n\n function isCrossLiquidation(Account.Props storage accountProps) external view returns (bool) {\n OracleProcess.OracleParam[] memory oracles;\n (, int256 crossNetValue, uint256 totalMM) = getCrossMMR(accountProps, oracles);\n return crossNetValue <= 0 || crossNetValue.toUint256() <= totalMM;\n }\n\n function getPortfolioNetValue(Account.Props storage accountProps) public view returns (uint256) {\n OracleProcess.OracleParam[] memory oracles;\n return getPortfolioNetValue(accountProps, oracles);\n }\n\n function getPortfolioNetValue(\n Account.Props storage accountProps,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (uint256) {\n uint256 totalNetValue;\n Config.Props storage config = Config.load();\n address[] memory tokens = accountProps.getTokens();\n for (uint256 i; i < tokens.length; i++) {\n if (!config.isTradeCollateralSupport(tokens[i])) {\n continue;\n }\n Account.TokenBalance memory tokenBalance = accountProps.tokenBalances[tokens[i]];\n totalNetValue = totalNetValue.add(_getTokenNetValue(tokens[i], tokenBalance, config, oracles));\n }\n return totalNetValue;\n }\n\n function getTotalUsedValue(Account.Props storage accountProps) public view returns (uint256) {\n OracleProcess.OracleParam[] memory oracles;\n return getTotalUsedValue(accountProps, oracles);\n }\n\n function getTotalUsedValue(\n Account.Props storage accountProps,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (uint256) {\n uint256 totalUsedValue;\n address[] memory tokens = accountProps.getTokens();\n Config.Props storage config = Config.load();\n for (uint256 i; i < tokens.length; i++) {\n Account.TokenBalance memory tokenBalance = accountProps.tokenBalances[tokens[i]];\n totalUsedValue = totalUsedValue.add(_getTokenUsedValue(tokens[i], tokenBalance, config, oracles));\n }\n if (accountProps.orderHoldInUsd > 0) {\n totalUsedValue += accountProps.orderHoldInUsd;\n }\n return totalUsedValue;\n }\n\n function getCrossUsedValueAndBorrowingValue(\n Account.Props storage accountProps,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (uint256, uint256) {\n uint256 totalUsedValue;\n uint256 totalBorrowingValue;\n address[] memory tokens = accountProps.getTokens();\n Config.Props storage config = Config.load();\n for (uint256 i; i < tokens.length; i++) {\n Account.TokenBalance memory tokenBalance = accountProps.tokenBalances[tokens[i]];\n totalUsedValue = totalUsedValue.add(_getTokenUsedValue(tokens[i], tokenBalance, config, oracles));\n uint256 positionUsedAmount = tokenBalance.usedAmount - tokenBalance.liability;\n if (positionUsedAmount > tokenBalance.amount) {\n totalBorrowingValue += CalUtils.tokenToUsd(\n positionUsedAmount - tokenBalance.amount,\n TokenUtils.decimals(tokens[i]),\n OracleProcess.getOraclePrices(oracles, tokens[i], true)\n );\n }\n }\n if (accountProps.orderHoldInUsd > 0) {\n totalUsedValue += accountProps.orderHoldInUsd;\n }\n return (totalUsedValue, totalBorrowingValue);\n }\n\n function getCrossNetValueAndTotalQty(\n Account.Props storage accountProps\n ) public view returns (uint256 crossNetValue, uint256 totalQty) {\n uint256 portfolioNetValue = getPortfolioNetValue(accountProps);\n uint256 totalUsedValue = getTotalUsedValue(accountProps);\n PositionQueryProcess.PositionStaticsCache memory cache = PositionQueryProcess.getAccountAllCrossPositionValue(\n accountProps\n );\n int256 crossNetValueInt = portfolioNetValue.toInt256() +\n cache.totalIMUsd.toInt256() +\n cache.totalPnl -\n totalUsedValue.toInt256() -\n cache.totalPosFee;\n crossNetValue = crossNetValueInt <= 0 ? 0 : crossNetValueInt.toUint256();\n totalQty = cache.totalQty;\n }\n\n function getCrossAvailableValue(Account.Props storage accountProps) public view returns (int256) {\n OracleProcess.OracleParam[] memory oracles;\n return getCrossAvailableValue(accountProps, oracles);\n }\n\n function getCrossAvailableValue(\n Account.Props storage accountProps,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (int256) {\n uint256 totalNetValue = getPortfolioNetValue(accountProps, oracles);\n (uint256 totalUsedValue, uint256 totalBorrowingValue) = getCrossUsedValueAndBorrowingValue(\n accountProps,\n oracles\n );\n\n PositionQueryProcess.PositionStaticsCache memory cache = PositionQueryProcess.getAccountAllCrossPositionValue(\n accountProps,\n oracles\n );\n return\n totalNetValue.toInt256() +\n cache.totalIMUsd.toInt256() -\n totalUsedValue.toInt256() +\n (cache.totalPnl >= 0 ? int256(0) : cache.totalPnl) -\n (cache.totalIMUsdFromBalance + totalBorrowingValue).toInt256();\n }\n\n function _getTokenNetValue(\n address token,\n Account.TokenBalance memory tokenBalance,\n Config.Props storage config,\n OracleProcess.OracleParam[] memory oracles\n ) internal view returns (uint256) {\n if (tokenBalance.amount > tokenBalance.usedAmount) {\n uint256 tokenValue = CalUtils.tokenToUsd(\n tokenBalance.amount - tokenBalance.usedAmount,\n TokenUtils.decimals(token),\n OracleProcess.getOraclePrices(oracles, token, true)\n );\n return CalUtils.mulRate(tokenValue, config.getTradeCollateralDiscount(token));\n }\n return 0;\n }\n\n function _getTokenUsedValue(\n address token,\n Account.TokenBalance memory tokenBalance,\n Config.Props storage config,\n OracleProcess.OracleParam[] memory oracles\n ) internal view returns (uint256) {\n if (tokenBalance.usedAmount > tokenBalance.amount) {\n uint256 tokenUsedValue = CalUtils.tokenToUsd(\n tokenBalance.usedAmount - tokenBalance.amount,\n TokenUtils.decimals(token),\n OracleProcess.getOraclePrices(oracles, token, true)\n );\n if (config.getTradeTokenConfig(token).liquidationFactor > 0) {\n return\n tokenUsedValue +\n CalUtils.mulRate(tokenUsedValue, config.getTradeTokenConfig(token).liquidationFactor);\n } else {\n return tokenUsedValue;\n }\n }\n return 0;\n }\n}\n" + }, + "contracts/process/AssetsProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../utils/TransferUtils.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../storage/Withdraw.sol\";\nimport \"../storage/Order.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"./AccountProcess.sol\";\nimport \"./VaultProcess.sol\";\n\nlibrary AssetsProcess {\n using SafeERC20 for IERC20;\n using SafeCast for uint256;\n using SafeCast for int256;\n using Account for Account.Props;\n using Config for Config.Props;\n using Position for Position.Props;\n using Order for Order.Props;\n using CommonData for CommonData.Props;\n\n struct UpdateAccountTokenParams {\n address account;\n address[] tokens;\n int256[] changedTokenAmounts;\n }\n\n bytes32 constant WITHDRAW_ID_KEY = keccak256(\"WITHDRAW_ID_KEY\");\n\n event CreateWithdrawEvent(uint256 indexed requestId, Withdraw.Request data);\n event WithdrawSuccessEvent(uint256 indexed requestId, Withdraw.Request data);\n event CancelWithdrawEvent(uint256 indexed requestId, Withdraw.Request data, bytes32 reasonCode);\n event Deposit(DepositParams data);\n\n enum DepositFrom {\n MANUAL,\n ORDER,\n MINT,\n MINT_COLLATERAL\n }\n\n struct DepositParams {\n address account;\n address token;\n uint256 amount;\n DepositFrom from;\n bool isNativeToken;\n }\n\n struct WithdrawParams {\n address stakeToken;\n address account;\n address token;\n uint256 amount;\n }\n\n function depositToVault(DepositParams calldata params) public returns (address) {\n IVault vault = IVault(address(this));\n address targetAddress;\n if (DepositFrom.MANUAL == params.from || DepositFrom.MINT_COLLATERAL == params.from) {\n targetAddress = vault.getPortfolioVaultAddress();\n } else if (DepositFrom.ORDER == params.from) {\n targetAddress = vault.getTradeVaultAddress();\n } else if (DepositFrom.MINT == params.from) {\n targetAddress = vault.getLpVaultAddress();\n }\n address token = params.token;\n if (params.isNativeToken) {\n address wrapperToken = Config.load().getWrapperToken();\n require(wrapperToken == params.token, \"Deposit with token error!\");\n IWETH(wrapperToken).deposit{ value: params.amount }();\n token = wrapperToken;\n TransferUtils.transfer(token, targetAddress, params.amount);\n } else {\n IERC20(token).safeTransferFrom(params.account, targetAddress, params.amount);\n }\n return token;\n }\n\n function deposit(DepositParams calldata params) external {\n address token = depositToVault(params);\n Account.Props storage accountProps = Account.load(params.account);\n if (DepositFrom.MANUAL == params.from) {\n Config.Props storage config = Config.load();\n if (!config.isTradeCollateralSupport(token)) {\n revert Errors.TokenIsNotSupportCollateral();\n }\n CommonData.Props storage commonData = CommonData.load();\n uint256 collateralAmount = commonData.getTradeTokenCollateral(token);\n if (collateralAmount + params.amount > config.getTradeTokenConfig(token).collateralTotalCap) {\n revert Errors.CollateralTotalCapOverflow(token, config.getTradeTokenConfig(token).collateralTotalCap);\n }\n if (accountProps.getTokenAmount(token) > config.getTradeTokenConfig(params.token).collateralUserCap) {\n revert Errors.CollateralUserCapOverflow(token, config.getTradeTokenConfig(token).collateralUserCap);\n }\n commonData.addTradeTokenCollateral(token, params.amount);\n }\n if (accountProps.owner == address(0)) {\n accountProps.owner = params.account;\n }\n accountProps.addToken(token, params.amount);\n if (DepositFrom.MINT != params.from) {\n accountProps.repayLiability(token);\n }\n\n emit Deposit(params);\n }\n\n function withdraw(WithdrawParams memory params) public {\n if (params.amount == 0) {\n revert Errors.AmountZeroNotAllowed();\n }\n Config.Props storage config = Config.load();\n if (!config.isTradeTokenSupport(params.token)) {\n revert Errors.OnlyCollateralSupported();\n }\n Account.Props storage accountProps = Account.load(params.account);\n\n if (accountProps.getTokenAmount(params.token) < params.amount) {\n revert Errors.WithdrawWithNoEnoughAmount();\n }\n uint256 tokenPrice = OracleProcess.getLatestUsdUintPrice(params.token, false);\n int256 amountInUsd = CalUtils\n .tokenToUsd(params.amount, TokenUtils.decimals(params.token), tokenPrice)\n .toInt256();\n if (_hasCrossUsed(accountProps) && AccountProcess.getCrossAvailableValue(accountProps) < amountInUsd) {\n revert Errors.WithdrawWithNoEnoughAmount();\n }\n accountProps.subToken(params.token, params.amount);\n VaultProcess.transferOut(\n IVault(address(this)).getPortfolioVaultAddress(),\n params.token,\n params.account,\n params.amount\n );\n }\n\n function createWithdrawRequest(address token, uint256 amount) external {\n uint256 requestId = UuidCreator.nextId(WITHDRAW_ID_KEY);\n Withdraw.Request storage request = Withdraw.create(requestId);\n request.account = msg.sender;\n request.token = token;\n request.amount = amount;\n\n emit CreateWithdrawEvent(requestId, request);\n }\n\n function executeWithdraw(uint256 requestId, Withdraw.Request memory request) external {\n withdraw(WithdrawParams(address(0), request.account, request.token, request.amount));\n Withdraw.remove(requestId);\n\n emit WithdrawSuccessEvent(requestId, request);\n }\n\n function cancelWithdraw(uint256 requestId, Withdraw.Request memory request, bytes32 reasonCode) external {\n Withdraw.remove(requestId);\n emit CancelWithdrawEvent(requestId, request, reasonCode);\n }\n\n function updateAccountToken(UpdateAccountTokenParams calldata params) external {\n Account.Props storage accountProps = Account.load(params.account);\n accountProps.checkExists();\n for (uint256 i; i < params.tokens.length; i++) {\n if (params.changedTokenAmounts[i] > 0) {\n accountProps.addToken(params.tokens[i], params.changedTokenAmounts[i].toUint256());\n accountProps.repayLiability(params.tokens[i]);\n } else {\n accountProps.subToken(params.tokens[i], params.changedTokenAmounts[i].toUint256());\n }\n }\n }\n\n function _hasCrossUsed(Account.Props storage account) internal view returns (bool) {\n if (account.hasLiability()) {\n return true;\n }\n uint256[] memory orders = account.getOrders();\n Order.Props storage orderProps = Order.load();\n for (uint256 i; i < orders.length; i++) {\n if (orderProps.get(orders[i]).isCrossMargin) {\n return true;\n }\n }\n bytes32[] memory positionKeys = account.getAllPosition();\n for (uint256 i; i < positionKeys.length; i++) {\n Position.Props storage position = Position.load(positionKeys[i]);\n if (position.isCrossMargin) {\n return true;\n }\n }\n return false;\n }\n}\n" + }, + "contracts/process/AutoReduceProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"./RedeemProcess.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./DecreasePositionProcess.sol\";\nimport \"./CancelOrderProcess.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary AutoReduceProcess {\n using DecreasePositionProcess for Position.Props;\n using Position for Position.Props;\n using Account for Account.Props;\n using StakingAccount for StakingAccount.Props;\n using Config for Config.Props;\n using Order for Order.Props;\n\n bytes32 constant AUTO_REDUCE_ID_KEY = keccak256(\"AUTO_REDUCE_ID_KEY\");\n\n function autoRedeem(address stakeToken, address[] calldata accounts, address collateral) external {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n Config.Props storage config = Config.load();\n for (uint256 i; i < accounts.length; i++) {\n StakingAccount.Props storage stakingAccountProps = StakingAccount.load(accounts[i]);\n StakingAccount.CollateralData memory data = stakingAccountProps.getCollateralToken(stakeToken, collateral);\n if (data.amount == 0 || data.stakeLiability == 0) {\n return;\n }\n uint256 collateralPrice = OracleProcess.getLatestUsdUintPrice(collateral, pool.baseToken, true);\n uint256 toStakeLiabilityAmount = CalUtils.tokenToToken(\n data.amount,\n TokenUtils.decimals(collateral),\n TokenUtils.decimals(pool.baseToken),\n collateralPrice\n );\n if (\n toStakeLiabilityAmount >\n data.stakeLiability + CalUtils.mulRate(data.stakeLiability, config.getStakeConfig().collateralFactor)\n ) {\n revert Errors.LiquidationIgnored(accounts[i]);\n }\n RedeemProcess.autoRedeemStakeCollateral(pool, stakingAccountProps, collateral);\n }\n }\n\n function autoReducePositions(bytes32[] calldata positionKeys) external {\n for (uint256 i; i < positionKeys.length; i++) {\n _reducePosition(positionKeys[i]);\n }\n }\n\n function _reducePosition(bytes32 positionKey) internal {\n Position.Props storage position = Position.load(positionKey);\n if (position.qty == 0) {\n return;\n }\n CancelOrderProcess.cancelSymbolOrders(\n position.account,\n position.symbol,\n position.marginToken,\n CancelOrderProcess.CANCEL_ORDER_AUTO_REDUCE\n );\n uint256 indexPrice = OracleProcess.getLatestUsdUintPrice(position.indexToken, position.isLong);\n position.decreasePosition(\n DecreasePositionProcess.DecreasePositionParams(\n UuidCreator.nextId(AUTO_REDUCE_ID_KEY),\n position.symbol,\n false,\n position.isCrossMargin,\n position.marginToken,\n position.qty,\n indexPrice\n )\n );\n }\n}\n" + }, + "contracts/process/CancelOrderProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../interfaces/IVault.sol\";\nimport \"./VaultProcess.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/Order.sol\";\n\nlibrary CancelOrderProcess {\n using Order for Order.Props;\n using Account for Account.Props;\n\n bytes32 public constant CANCEL_ORDER_LIQUIDATION = bytes32(abi.encode(\"CANCEL_WITH_LIQUIDATION\"));\n bytes32 public constant CANCEL_ORDER_AUTO_REDUCE = bytes32(abi.encode(\"CANCEL_WITH_AUTO_REDUCE\"));\n bytes32 public constant CANCEL_ORDER_POSITION_CLOSE = bytes32(abi.encode(\"CANCEL_WITH_POSITION_CLOSE\"));\n\n event CancelOrderEvent(uint256 indexed orderId, Order.OrderInfo data, bytes32 reasonCode);\n\n function cancelAllCrossOrders(address account, bytes32 reasonCode) internal {\n Account.Props storage accountProps = Account.load(account);\n uint256[] memory orders = accountProps.getOrders();\n if (orders.length == 0) {\n return;\n }\n Order.Props storage orderProps = Order.load();\n for (uint256 i; i < orders.length; i++) {\n Order.OrderInfo memory order = orderProps.get(orders[i]);\n if (order.isCrossMargin) {\n orderProps.remove(orders[i]);\n accountProps.delOrder(orders[i]);\n if (Order.PositionSide.INCREASE == order.posSide) {\n accountProps.subOrderHoldInUsd(order.orderMargin);\n }\n emit CancelOrderEvent(orders[i], order, reasonCode);\n }\n }\n }\n\n function cancelSymbolOrders(address account, bytes32 symbol, address marginToken, bytes32 reasonCode) internal {\n Account.Props storage accountProps = Account.load(account);\n uint256[] memory orders = accountProps.getOrders();\n if (orders.length == 0) {\n return;\n }\n Order.Props storage orderProps = Order.load();\n for (uint256 i; i < orders.length; i++) {\n Order.OrderInfo memory order = orderProps.get(orders[i]);\n if (order.symbol == symbol && order.marginToken == marginToken && order.isCrossMargin == false) {\n orderProps.remove(orders[i]);\n accountProps.delOrder(orders[i]);\n if (Order.PositionSide.INCREASE == order.posSide) {\n VaultProcess.transferOut(\n IVault(address(this)).getTradeVaultAddress(),\n order.marginToken,\n order.account,\n order.orderMargin\n );\n }\n emit CancelOrderEvent(orders[i], order, reasonCode);\n }\n }\n }\n\n function cancelStopOrders(address account, bytes32 symbol, address marginToken, bool isCrossMargin, bytes32 reasonCode) external {\n Account.Props storage accountProps = Account.load(account);\n uint256[] memory orderIds = accountProps.getAllOrders();\n if (orderIds.length > 0) {\n Order.Props storage orderPros = Order.load();\n for (uint256 i; i < orderIds.length; i++) {\n Order.OrderInfo storage orderInfo = orderPros.get(orderIds[i]);\n if (\n orderInfo.symbol == symbol &&\n orderInfo.marginToken == marginToken &&\n Order.Type.STOP == orderInfo.orderType &&\n orderInfo.isCrossMargin == isCrossMargin\n ) {\n accountProps.delOrder(orderIds[i]);\n orderPros.remove(orderIds[i]);\n emit CancelOrderEvent(orderIds[i], orderInfo, reasonCode);\n }\n }\n }\n }\n\n function cancelOrder(uint256 orderId, Order.OrderInfo memory order, bytes32 reasonCode) external {\n Account.Props storage accountProps = Account.load(order.account);\n accountProps.delOrder(orderId);\n Order.remove(orderId);\n if (Order.PositionSide.INCREASE == order.posSide) {\n if (order.isCrossMargin == true) {\n accountProps.subOrderHoldInUsd(order.orderMargin);\n } else {\n VaultProcess.transferOut(\n IVault(address(this)).getTradeVaultAddress(),\n order.marginToken,\n order.account,\n order.orderMargin\n );\n }\n }\n emit CancelOrderEvent(orderId, order, reasonCode);\n }\n}\n" + }, + "contracts/process/ClaimRewardsProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/IFee.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/FeeRewards.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../storage/ClaimRewards.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"./VaultProcess.sol\";\nimport \"./LpPoolQueryProcess.sol\";\nimport \"./GasProcess.sol\";\nimport \"./AssetsProcess.sol\";\nimport \"./FeeRewardsProcess.sol\";\n\nlibrary ClaimRewardsProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeERC20 for IERC20;\n using Config for Config.Props;\n using UsdPool for UsdPool.Props;\n using LpPool for LpPool.Props;\n using LpPoolQueryProcess for LpPool.Props;\n using LpPoolQueryProcess for UsdPool.Props;\n using StakingAccount for StakingAccount.Props;\n using FeeRewards for FeeRewards.MarketRewards;\n using FeeRewards for FeeRewards.StakingRewards;\n\n bytes32 constant CLAIM_ID_KEY = keccak256(\"CLAIM_ID_KEY\");\n\n event CreateClaimRewardsEvent(uint256 indexed requestId, ClaimRewards.Request data);\n event ClaimRewardsSuccessEvent(uint256 indexed requestId, ClaimRewards.Request data);\n event CancelClaimRewardsEvent(uint256 indexed requestId, ClaimRewards.Request data, bytes32 reasonCode);\n\n function createClaimRewards(address account, address claimUsdToken, uint256 executionFee) external {\n if (!UsdPool.isSupportStableToken(claimUsdToken)) {\n revert Errors.ClaimTokenNotSupported();\n }\n Config.Props storage config = Config.load();\n GasProcess.validateExecutionFeeLimit(executionFee, config.chainConfig.claimRewardsGasFeeLimit);\n require(msg.value == executionFee, \"claim rewards with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n account,\n config.chainConfig.wrapperToken,\n executionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n uint256 requestId = UuidCreator.nextId(CLAIM_ID_KEY);\n ClaimRewards.Request storage request = ClaimRewards.create(requestId);\n request.account = account;\n request.claimUsdToken = claimUsdToken;\n request.executionFee = executionFee;\n emit CreateClaimRewardsEvent(requestId, request);\n }\n\n function claimRewards(uint256 requestId, ClaimRewards.Request memory request) external {\n address account = request.account;\n address[] memory stakeTokens = CommonData.getAllStakeTokens();\n StakingAccount.Props storage stakingAccount = StakingAccount.load(account);\n StakingAccount.FeeRewards storage accountFeeRewards;\n for (uint256 i; i < stakeTokens.length; i++) {\n address stakeToken = stakeTokens[i];\n FeeRewards.MarketRewards storage feeProps = FeeRewards.loadPoolRewards(stakeToken);\n FeeRewardsProcess.updateAccountFeeRewards(account, stakeToken);\n accountFeeRewards = stakingAccount.getFeeRewards(stakeToken);\n if (accountFeeRewards.realisedRewardsTokenAmount == 0) {\n continue;\n }\n LpPool.Props storage pool = LpPool.load(stakeToken);\n uint256 withdrawPoolAmount = accountFeeRewards.realisedRewardsTokenAmount;\n pool.subBaseToken(withdrawPoolAmount);\n VaultProcess.transferOut(stakeToken, pool.baseToken, account, withdrawPoolAmount);\n accountFeeRewards.realisedRewardsTokenAmount = 0;\n accountFeeRewards.openRewardsPerStakeToken = feeProps.getCumulativeRewardsPerStakeToken();\n }\n\n accountFeeRewards = stakingAccount.getFeeRewards(\n CommonData.getStakeUsdToken()\n );\n uint256 withdrawAmount = CalUtils.usdToToken(\n accountFeeRewards.realisedRewardsTokenAmount,\n TokenUtils.decimals(request.claimUsdToken),\n OracleProcess.getLatestUsdUintPrice(request.claimUsdToken, false)\n );\n UsdPool.Props storage usdPool = UsdPool.load();\n usdPool.subStableToken(request.claimUsdToken, withdrawAmount);\n VaultProcess.transferOut(CommonData.getStakeUsdToken(), request.claimUsdToken, account, withdrawAmount);\n\n ClaimRewards.remove(requestId);\n emit ClaimRewardsSuccessEvent(requestId, request);\n }\n\n function cancelClaimRewards(uint256 requestId, ClaimRewards.Request memory request, bytes32 reasonCode) external {\n ClaimRewards.remove(requestId);\n emit CancelClaimRewardsEvent(requestId, request, reasonCode);\n }\n}\n" + }, + "contracts/process/ConfigProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"../interfaces/IConfig.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary ConfigProcess {\n using Config for Config.Props;\n using LpPool for LpPool.Props;\n using UsdPool for UsdPool.Props;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n function getConfig() external view returns (IConfig.CommonConfigParams memory config) {\n Config.Props storage configProps = Config.load();\n config.mintGasFeeLimit = configProps.chainConfig.mintGasFeeLimit;\n config.redeemGasFeeLimit = configProps.chainConfig.redeemGasFeeLimit;\n config.placeIncreaseOrderGasFeeLimit = configProps.chainConfig.placeIncreaseOrderGasFeeLimit;\n config.placeDecreaseOrderGasFeeLimit = configProps.chainConfig.placeDecreaseOrderGasFeeLimit;\n config.positionUpdateMarginGasFeeLimit = configProps.chainConfig.positionUpdateMarginGasFeeLimit;\n config.positionUpdateLeverageGasFeeLimit = configProps.chainConfig.positionUpdateLeverageGasFeeLimit;\n config.claimRewardsGasFeeLimit = configProps.chainConfig.claimRewardsGasFeeLimit;\n config.tradeTokens = configProps.tradeConfig.tokens.values();\n config.tradeTokenConfigs = new Config.TradeTokenConfig[](config.tradeTokens.length);\n for (uint256 i; i < config.tradeTokens.length; i++) {\n config.tradeTokenConfigs[i] = configProps.tradeConfig.tokenConfigs[config.tradeTokens[i]];\n }\n config.minOrderMarginUSD = configProps.tradeConfig.minOrderMarginUSD;\n config.availableCollateralRatio = configProps.tradeConfig.availableCollateralRatio;\n config.crossLtvLimit = configProps.tradeConfig.crossLtvLimit;\n config.executeOrderMinBlockGap = configProps.tradeConfig.executeOrderMinBlockGap;\n config.executeOrderMaxBlockGap = configProps.tradeConfig.executeOrderMaxBlockGap;\n config.executePositionMarginMinBlockGap = configProps.tradeConfig.executePositionMarginMinBlockGap;\n config.executePositionMarginMaxBlockGap = configProps.tradeConfig.executePositionMarginMaxBlockGap;\n config.executeLeverageMinBlockGap = configProps.tradeConfig.executeLeverageMinBlockGap;\n config.executeLeverageMaxBlockGap = configProps.tradeConfig.executeLeverageMaxBlockGap;\n config.maxMaintenanceMarginRate = configProps.tradeConfig.maxMaintenanceMarginRate;\n config.fundingFeeBaseRate = configProps.tradeConfig.fundingFeeBaseRate;\n config.minPrecisionMultiple = configProps.stakeConfig.minPrecisionMultiple;\n config.stakeCollateralProtectFactor = configProps.stakeConfig.collateralProtectFactor;\n config.stakeCollateralFactor = configProps.stakeConfig.collateralFactor;\n config.tradingFeeStakingRewardsRatio = configProps.tradeConfig.tradingFeeStakingRewardsRatio;\n config.tradingFeePoolRewardsRatio = configProps.tradeConfig.tradingFeePoolRewardsRatio;\n config.tradingFeeUsdPoolRewardsRatio = configProps.tradeConfig.tradingFeeUsdPoolRewardsRatio;\n config.borrowingFeeStakingRewardsRatio = configProps.tradeConfig.borrowingFeeStakingRewardsRatio;\n config.borrowingFeePoolRewardsRatio = configProps.tradeConfig.borrowingFeePoolRewardsRatio;\n config.autoReduceProfitFactor = configProps.tradeConfig.autoReduceProfitFactor;\n config.autoReduceLiquidityFactor = configProps.tradeConfig.autoReduceLiquidityFactor;\n config.swapSlipperTokenFactor = configProps.tradeConfig.swapSlipperTokenFactor;\n config.mintFeeStakingRewardsRatio = configProps.stakeConfig.mintFeeStakingRewardsRatio;\n config.mintFeePoolRewardsRatio = configProps.stakeConfig.mintFeePoolRewardsRatio;\n config.redeemFeeStakingRewardsRatio = configProps.stakeConfig.redeemFeeStakingRewardsRatio;\n config.redeemFeePoolRewardsRatio = configProps.stakeConfig.redeemFeePoolRewardsRatio;\n config.uniswapRouter = configProps.commonConfig.uniswapRouter;\n config.poolRewardsIntervalLimit = configProps.stakeConfig.poolRewardsIntervalLimit;\n }\n\n function setConfig(IConfig.CommonConfigParams calldata params) external {\n Config.Props storage config = Config.load();\n config.chainConfig.wrapperToken = params.wrapperToken;\n config.chainConfig.mintGasFeeLimit = params.mintGasFeeLimit;\n config.chainConfig.redeemGasFeeLimit = params.redeemGasFeeLimit;\n config.chainConfig.placeIncreaseOrderGasFeeLimit = params.placeIncreaseOrderGasFeeLimit;\n config.chainConfig.placeDecreaseOrderGasFeeLimit = params.placeDecreaseOrderGasFeeLimit;\n config.chainConfig.positionUpdateMarginGasFeeLimit = params.positionUpdateMarginGasFeeLimit;\n config.chainConfig.positionUpdateLeverageGasFeeLimit = params.positionUpdateLeverageGasFeeLimit;\n config.chainConfig.claimRewardsGasFeeLimit = params.claimRewardsGasFeeLimit;\n for (uint256 i; i < params.tradeTokens.length; i++) {\n config.addTradeToken(params.tradeTokens[i], params.tradeTokenConfigs[i]);\n }\n config.tradeConfig.minOrderMarginUSD = params.minOrderMarginUSD;\n config.tradeConfig.availableCollateralRatio = params.availableCollateralRatio;\n config.tradeConfig.crossLtvLimit = params.crossLtvLimit;\n config.tradeConfig.executeOrderMinBlockGap = params.executeOrderMinBlockGap;\n config.tradeConfig.executeOrderMaxBlockGap = params.executeOrderMaxBlockGap;\n config.tradeConfig.executePositionMarginMinBlockGap = params.executePositionMarginMinBlockGap;\n config.tradeConfig.executePositionMarginMaxBlockGap = params.executePositionMarginMaxBlockGap;\n config.tradeConfig.executeLeverageMinBlockGap = params.executeLeverageMinBlockGap;\n config.tradeConfig.executeLeverageMaxBlockGap = params.executeLeverageMaxBlockGap;\n config.tradeConfig.maxMaintenanceMarginRate = params.maxMaintenanceMarginRate;\n config.tradeConfig.fundingFeeBaseRate = params.fundingFeeBaseRate;\n config.tradeConfig.tradingFeeStakingRewardsRatio = params.tradingFeeStakingRewardsRatio;\n config.tradeConfig.tradingFeePoolRewardsRatio = params.tradingFeePoolRewardsRatio;\n config.tradeConfig.tradingFeeUsdPoolRewardsRatio = params.tradingFeeUsdPoolRewardsRatio;\n config.tradeConfig.borrowingFeeStakingRewardsRatio = params.borrowingFeeStakingRewardsRatio;\n config.tradeConfig.borrowingFeePoolRewardsRatio = params.borrowingFeePoolRewardsRatio;\n config.tradeConfig.autoReduceProfitFactor = params.autoReduceProfitFactor;\n config.tradeConfig.autoReduceLiquidityFactor = params.autoReduceLiquidityFactor;\n config.tradeConfig.swapSlipperTokenFactor = params.swapSlipperTokenFactor;\n \n config.stakeConfig.collateralFactor = params.stakeCollateralFactor;\n config.stakeConfig.collateralProtectFactor = params.stakeCollateralProtectFactor;\n config.stakeConfig.minPrecisionMultiple = params.minPrecisionMultiple;\n config.stakeConfig.mintFeeStakingRewardsRatio = params.mintFeeStakingRewardsRatio;\n config.stakeConfig.mintFeePoolRewardsRatio = params.mintFeePoolRewardsRatio;\n config.stakeConfig.redeemFeeStakingRewardsRatio = params.redeemFeeStakingRewardsRatio;\n config.stakeConfig.redeemFeePoolRewardsRatio = params.redeemFeePoolRewardsRatio;\n config.commonConfig.uniswapRouter = params.uniswapRouter;\n config.stakeConfig.poolRewardsIntervalLimit = params.poolRewardsIntervalLimit;\n }\n\n function getPoolConfig(address stakeToken) public view returns (IConfig.LpPoolConfigParams memory config) {\n Config.LpPoolConfig storage lpPoolConfig = Config.load().getPoolConfig(stakeToken);\n config.assetTokens = lpPoolConfig.assetTokens;\n\n config.supportCollateralTokens = lpPoolConfig.supportCollateralTokens.values();\n config.collateralTokensConfigs = new Config.StakeCollateralConfig[](config.supportCollateralTokens.length);\n for (uint256 i; i < config.supportCollateralTokens.length; i++) {\n config.collateralTokensConfigs[i] = lpPoolConfig.collateralTokensConfigs[config.supportCollateralTokens[i]];\n }\n\n config.poolLiquidityLimit = lpPoolConfig.poolLiquidityLimit;\n config.mintFeeRate = lpPoolConfig.mintFeeRate;\n config.redeemFeeRate = lpPoolConfig.redeemFeeRate;\n config.stakeToken = stakeToken;\n config.baseInterestRate = lpPoolConfig.baseInterestRate;\n config.poolPnlRatioLimit = lpPoolConfig.poolPnlRatioLimit;\n config.collateralStakingRatioLimit = lpPoolConfig.collateralStakingRatioLimit;\n config.unsettledBaseTokenRatioLimit = lpPoolConfig.unsettledBaseTokenRatioLimit;\n config.unsettledStableTokenRatioLimit = lpPoolConfig.unsettledStableTokenRatioLimit;\n config.poolStableTokenRatioLimit = lpPoolConfig.poolStableTokenRatioLimit;\n config.poolStableTokenLossLimit = lpPoolConfig.poolStableTokenLossLimit;\n }\n\n function setPoolConfig(IConfig.LpPoolConfigParams memory params) external {\n LpPool.Props storage pool = LpPool.load(params.stakeToken);\n Config.LpPoolConfig storage poolConfig = Config.load().lpPoolConfigs[params.stakeToken];\n if (pool.stakeToken == address(0)) {\n revert Errors.PoolNotExists();\n }\n poolConfig.baseInterestRate = params.baseInterestRate;\n poolConfig.assetTokens = params.assetTokens;\n poolConfig.poolLiquidityLimit = params.poolLiquidityLimit;\n poolConfig.mintFeeRate = params.mintFeeRate;\n poolConfig.redeemFeeRate = params.redeemFeeRate;\n poolConfig.poolPnlRatioLimit = params.poolPnlRatioLimit;\n poolConfig.collateralStakingRatioLimit = params.collateralStakingRatioLimit;\n poolConfig.unsettledBaseTokenRatioLimit = params.unsettledBaseTokenRatioLimit;\n poolConfig.unsettledStableTokenRatioLimit = params.unsettledStableTokenRatioLimit;\n poolConfig.poolStableTokenRatioLimit = params.poolStableTokenRatioLimit;\n poolConfig.poolStableTokenLossLimit = params.poolStableTokenLossLimit;\n for (uint256 i; i < params.supportCollateralTokens.length; i++) {\n pool.addStakeCollateralToken(params.supportCollateralTokens[i], params.collateralTokensConfigs[i]);\n }\n }\n\n function getUsdPoolConfig() external view returns (IConfig.UsdPoolConfigParams memory config) {\n UsdPool.Props storage pool = UsdPool.load();\n Config.UsdPoolConfig storage usdPoolConfig = Config.load().usdPoolConfig;\n config.mintFeeRate = usdPoolConfig.mintFeeRate;\n config.poolLiquidityLimit = usdPoolConfig.poolLiquidityLimit;\n config.redeemFeeRate = usdPoolConfig.redeemFeeRate;\n config.unsettledRatioLimit = usdPoolConfig.unsettledRatioLimit;\n config.supportStableTokens = pool.stableTokens.values();\n config.stableTokensBorrowingInterestRate = new uint256[](config.supportStableTokens.length);\n config.stableTokensRatioLimit = new uint256[](config.supportStableTokens.length);\n for (uint256 i; i < config.supportStableTokens.length; i++) {\n config.stableTokensBorrowingInterestRate[i] = usdPoolConfig.baseInterestRates[\n config.supportStableTokens[i]\n ];\n config.stableTokensRatioLimit[i] = usdPoolConfig.stableTokenRatioLimits[config.supportStableTokens[i]];\n }\n }\n\n function setUsdPoolConfig(IConfig.UsdPoolConfigParams calldata params) external {\n UsdPool.Props storage pool = UsdPool.load();\n Config.UsdPoolConfig storage usdPoolConfig = Config.load().usdPoolConfig;\n pool.addSupportStableTokens(params.supportStableTokens);\n for (uint256 i; i < params.stableTokensBorrowingInterestRate.length; i++) {\n usdPoolConfig.baseInterestRates[params.supportStableTokens[i]] = params.stableTokensBorrowingInterestRate[\n i\n ];\n usdPoolConfig.stableTokenRatioLimits[params.supportStableTokens[i]] = params.stableTokensRatioLimit[i];\n }\n usdPoolConfig.poolLiquidityLimit = params.poolLiquidityLimit;\n usdPoolConfig.unsettledRatioLimit = params.unsettledRatioLimit;\n usdPoolConfig.mintFeeRate = params.mintFeeRate;\n usdPoolConfig.redeemFeeRate = params.redeemFeeRate;\n }\n\n function getSymbolConfig(bytes32 code) external view returns (IConfig.SymbolConfigParams memory config) {\n config.symbol = code;\n config.config = Config.load().getSymbolConfig(code);\n }\n\n function setSymbolConfig(IConfig.SymbolConfigParams calldata params) external {\n Config.SymbolConfig storage symbolConfig = Config.load().symbolConfigs[params.symbol];\n Symbol.Props storage symbolProps = Symbol.load(params.symbol);\n if (symbolProps.stakeToken == address(0)) {\n revert Errors.SymbolNotExists();\n }\n symbolConfig.maxLeverage = params.config.maxLeverage;\n symbolConfig.tickSize = params.config.tickSize;\n symbolConfig.openFeeRate = params.config.openFeeRate;\n symbolConfig.closeFeeRate = params.config.closeFeeRate;\n symbolConfig.maxLongOpenInterestCap = params.config.maxLongOpenInterestCap;\n symbolConfig.maxShortOpenInterestCap = params.config.maxShortOpenInterestCap;\n symbolConfig.longShortRatioLimit = params.config.longShortRatioLimit;\n symbolConfig.longShortOiBottomLimit = params.config.longShortOiBottomLimit;\n }\n}\n" + }, + "contracts/process/DecreasePositionProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/Order.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/InsuranceFund.sol\";\nimport \"../vault/TradeVault.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../utils/CommonUtils.sol\";\nimport \"./MarketProcess.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./LpPoolProcess.sol\";\nimport \"./FeeProcess.sol\";\nimport \"./VaultProcess.sol\";\nimport \"./AccountProcess.sol\";\nimport \"./CancelOrderProcess.sol\";\nimport \"./PositionQueryProcess.sol\";\nimport \"./FeeQueryProcess.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary DecreasePositionProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedSafeMath for int256;\n using Math for uint256;\n using Config for Config.Props;\n using Position for Position.Props;\n using Order for Order.Props;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n using Market for Market.Props;\n\n struct DecreasePositionParams {\n uint256 requestId;\n bytes32 symbol;\n bool isLiquidation;\n bool isCrossMargin;\n address marginToken;\n uint256 decreaseQty;\n uint256 executePrice;\n }\n\n struct DecreasePositionCache {\n address stakeToken;\n Position.Props position;\n uint256 marginTokenPrice;\n int256 executePrice;\n int256 recordPnlToken;\n int256 settledMargin;\n uint256 decreaseMargin;\n uint256 decreaseMarginInUsd;\n uint256 decreaseMarginInUsdFromBalance;\n uint256 settledBorrowingFee;\n uint256 settledBorrowingFeeInUsd;\n int256 settledFundingFee;\n int256 settledFundingFeeInUsd;\n uint256 unHoldPoolAmount;\n uint256 closeFee;\n uint256 closeFeeInUsd;\n int256 realizedPnl;\n int256 poolPnlToken;\n bool isLiquidation;\n }\n\n function decreasePosition(Position.Props storage position, DecreasePositionParams calldata params) external {\n int256 totalPnlInUsd = PositionQueryProcess.getPositionUnPnl(position, params.executePrice.toInt256(), false);\n Symbol.Props memory symbolProps = Symbol.load(params.symbol);\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(params.symbol);\n DecreasePositionCache memory cache = _updateDecreasePosition(\n position,\n params.decreaseQty,\n totalPnlInUsd,\n params.executePrice.toInt256(),\n symbolConfig.closeFeeRate,\n params.isLiquidation,\n params.isCrossMargin\n );\n if (cache.settledMargin < 0 && !cache.isLiquidation && !position.isCrossMargin) {\n revert Errors.PositionShouldBeLiquidation();\n }\n cache.stakeToken = symbolProps.stakeToken;\n cache.isLiquidation = params.isLiquidation;\n\n Account.Props storage accountProps = Account.load(position.account);\n if (params.decreaseQty == position.qty) {\n accountProps.delPosition(\n Position.getPositionKey(position.account, position.symbol, position.marginToken, position.isCrossMargin)\n );\n position.reset();\n } else {\n position.qty -= params.decreaseQty;\n position.initialMargin -= cache.decreaseMargin;\n position.initialMarginInUsd -= cache.decreaseMarginInUsd;\n position.initialMarginInUsdFromBalance -= cache.decreaseMarginInUsdFromBalance;\n position.positionFee.realizedBorrowingFee -= cache.settledBorrowingFee;\n position.positionFee.realizedBorrowingFeeInUsd -= cache.settledBorrowingFeeInUsd;\n position.holdPoolAmount -= cache.unHoldPoolAmount;\n position.realizedPnl += cache.realizedPnl;\n position.positionFee.closeFeeInUsd -= cache.closeFeeInUsd;\n position.lastUpdateTime = ChainUtils.currentTimestamp();\n }\n\n FeeProcess.chargeTradingFee(\n cache.closeFee,\n symbolProps.code,\n cache.isLiquidation ? FeeProcess.FEE_LIQUIDATION : FeeProcess.FEE_CLOSE_POSITION,\n cache.position.marginToken,\n cache.position\n );\n\n FeeProcess.chargeBorrowingFee(\n position.isCrossMargin,\n cache.settledBorrowingFee,\n symbolProps.stakeToken,\n cache.position.marginToken,\n position.account,\n cache.isLiquidation ? FeeProcess.FEE_LIQUIDATION : FeeProcess.FEE_BORROWING\n );\n\n uint256 addLiability = _settleAccount(accountProps, position, cache);\n if (cache.position.isCrossMargin && addLiability == 0) {\n accountProps.repayLiability(cache.position.marginToken);\n }\n // update pool hold\n LpPoolProcess.updatePnlAndUnHoldPoolAmount(\n symbolProps.stakeToken,\n cache.position.marginToken,\n cache.unHoldPoolAmount,\n cache.poolPnlToken,\n cache.isLiquidation && cache.position.isCrossMargin && cache.poolPnlToken > 0\n ? cache.poolPnlToken.toUint256()\n : addLiability\n );\n\n // update total borrowing\n MarketProcess.updateTotalBorrowingFee(\n symbolProps.stakeToken,\n cache.position.isLong,\n cache.position.marginToken,\n cache.settledBorrowingFee.toInt256(),\n -cache.settledBorrowingFee.toInt256()\n );\n\n // update funding fee\n MarketProcess.updateMarketFundingFee(\n symbolProps.code,\n -cache.settledFundingFee,\n cache.position.isLong,\n !position.isCrossMargin,\n cache.position.marginToken\n );\n\n // update & verify OI\n MarketProcess.updateMarketOI(\n MarketProcess.UpdateOIParams(\n false,\n symbolProps.code,\n cache.position.marginToken,\n params.decreaseQty,\n 0,\n cache.position.isLong\n )\n );\n\n // cancel stop orders\n CancelOrderProcess.cancelStopOrders(\n cache.position.account,\n symbolProps.code,\n cache.position.marginToken,\n cache.position.isCrossMargin,\n CancelOrderProcess.CANCEL_ORDER_POSITION_CLOSE\n );\n\n // update insuranceFund\n if (cache.isLiquidation) {\n InsuranceFund.addFunds(\n cache.stakeToken,\n cache.position.marginToken,\n cache.position.isCrossMargin\n ? CalUtils.usdToToken(\n PositionQueryProcess.getPositionMM(cache.position),\n TokenUtils.decimals(cache.position.marginToken),\n cache.marginTokenPrice\n )\n : (\n cache.decreaseMargin > cache.closeFee.add(cache.poolPnlToken.toUint256())\n ? cache.decreaseMargin.sub(cache.closeFee).sub(cache.poolPnlToken.toUint256())\n : 0\n )\n );\n position.emitPositionUpdateEvent(\n params.requestId,\n Position.PositionUpdateFrom.LIQUIDATION,\n params.executePrice\n );\n } else {\n position.emitPositionUpdateEvent(\n params.requestId,\n Position.PositionUpdateFrom.ORDER_DECREASE,\n params.executePrice\n );\n }\n }\n\n function _updateDecreasePosition(\n Position.Props storage position,\n uint256 decreaseQty,\n int256 pnlInUsd,\n int256 executePrice,\n uint256 closeFeeRate,\n bool isLiquidation,\n bool isCrossMargin\n ) internal view returns (DecreasePositionCache memory cache) {\n cache.position = position;\n cache.executePrice = executePrice;\n int256 tokenPrice = OracleProcess.getLatestUsdPrice(position.marginToken, false);\n cache.marginTokenPrice = tokenPrice.toUint256();\n uint8 tokenDecimals = TokenUtils.decimals(position.marginToken);\n if (position.qty == decreaseQty) {\n cache.decreaseMargin = cache.position.initialMargin;\n cache.decreaseMarginInUsd = cache.position.initialMarginInUsd;\n cache.unHoldPoolAmount = cache.position.holdPoolAmount;\n (cache.settledBorrowingFee, cache.settledBorrowingFeeInUsd) = FeeQueryProcess.calcBorrowingFee(\n decreaseQty,\n position\n );\n cache.settledFundingFee = cache.position.positionFee.realizedFundingFee;\n cache.settledFundingFeeInUsd = cache.position.positionFee.realizedFundingFeeInUsd;\n\n cache.closeFeeInUsd = cache.position.positionFee.closeFeeInUsd;\n cache.closeFee = FeeQueryProcess.calcCloseFee(tokenDecimals, cache.closeFeeInUsd, tokenPrice.toUint256());\n\n if (isLiquidation) {\n cache.settledMargin = isCrossMargin\n ? CalUtils.usdToTokenInt(\n cache.position.initialMarginInUsd.toInt256() -\n _getPosFee(cache) +\n pnlInUsd -\n PositionQueryProcess.getPositionMM(cache.position).toInt256(),\n TokenUtils.decimals(cache.position.marginToken),\n tokenPrice\n )\n : int256(0);\n cache.recordPnlToken = cache.settledMargin - cache.decreaseMargin.toInt256();\n cache.poolPnlToken =\n cache.decreaseMargin.toInt256() -\n CalUtils.usdToTokenInt(\n cache.position.initialMarginInUsd.toInt256() + pnlInUsd,\n TokenUtils.decimals(cache.position.marginToken),\n tokenPrice\n );\n } else {\n cache.settledMargin = CalUtils.usdToTokenInt(\n cache.position.initialMarginInUsd.toInt256() - _getPosFee(cache) + pnlInUsd,\n TokenUtils.decimals(cache.position.marginToken),\n tokenPrice\n );\n cache.recordPnlToken = cache.settledMargin - cache.decreaseMargin.toInt256();\n cache.poolPnlToken = cache.recordPnlToken > 0\n ? -cache.recordPnlToken - cache.closeFee.toInt256()\n : -cache.recordPnlToken;\n }\n cache.realizedPnl = pnlInUsd;\n } else {\n cache.decreaseMargin = cache.position.initialMargin.mul(decreaseQty).div(cache.position.qty);\n cache.unHoldPoolAmount = cache.position.holdPoolAmount.mul(decreaseQty).div(cache.position.qty);\n cache.closeFeeInUsd = CalUtils.mulRate(decreaseQty, closeFeeRate);\n (cache.settledBorrowingFee, cache.settledBorrowingFeeInUsd) = FeeQueryProcess.calcBorrowingFee(\n decreaseQty,\n position\n );\n cache.settledFundingFee = cache.position.positionFee.realizedFundingFee.mul(decreaseQty.toInt256()).div(\n cache.position.qty.toInt256()\n );\n cache.settledFundingFeeInUsd = cache\n .position\n .positionFee\n .realizedFundingFeeInUsd\n .mul(decreaseQty.toInt256())\n .div(cache.position.qty.toInt256());\n\n if (cache.closeFeeInUsd > cache.position.positionFee.closeFeeInUsd) {\n cache.closeFeeInUsd = cache.position.positionFee.closeFeeInUsd;\n }\n cache.closeFee = FeeQueryProcess.calcCloseFee(tokenDecimals, cache.closeFeeInUsd, tokenPrice.toUint256());\n\n cache.settledMargin = CalUtils.usdToTokenInt(\n (cache.position.initialMarginInUsd.toInt256() - _getPosFee(cache) + pnlInUsd)\n .mul(decreaseQty.toInt256())\n .div(cache.position.qty.toInt256()),\n TokenUtils.decimals(cache.position.marginToken),\n tokenPrice\n );\n cache.recordPnlToken = cache.settledMargin - cache.decreaseMargin.toInt256();\n cache.poolPnlToken = cache.recordPnlToken > 0\n ? -cache.recordPnlToken - cache.closeFee.toInt256()\n : -cache.recordPnlToken;\n cache.decreaseMarginInUsd = cache.position.initialMarginInUsd.mul(decreaseQty).div(position.qty);\n cache.realizedPnl = pnlInUsd.mul(decreaseQty.toInt256()).div(position.qty.toInt256());\n }\n\n cache.decreaseMarginInUsdFromBalance = (cache.decreaseMarginInUsd + position.initialMarginInUsdFromBalance >\n position.initialMarginInUsd)\n ? cache.decreaseMarginInUsd + position.initialMarginInUsdFromBalance - position.initialMarginInUsd\n : 0;\n\n return cache;\n }\n\n function _settleAccount(\n Account.Props storage accountProps,\n Position.Props storage position,\n DecreasePositionCache memory cache\n ) internal returns (uint256 addLiability) {\n if (position.isCrossMargin) {\n accountProps.subTokenWithLiability(cache.position.marginToken, cache.closeFee);\n accountProps.unUseToken(cache.position.marginToken, cache.decreaseMargin);\n address portfolioVault = IVault(address(this)).getPortfolioVaultAddress();\n if (cache.recordPnlToken >= 0) {\n accountProps.addToken(\n cache.position.marginToken,\n cache.recordPnlToken.toUint256(),\n !cache.isLiquidation\n );\n VaultProcess.transferOut(\n cache.position.isLong ? cache.stakeToken : CommonData.getStakeUsdToken(),\n cache.position.marginToken,\n portfolioVault,\n cache.position.isLong\n ? cache.recordPnlToken.toUint256()\n : cache.recordPnlToken.toUint256() + cache.closeFee,\n true\n );\n } else if (cache.recordPnlToken < 0) {\n addLiability = accountProps.subTokenWithLiability(\n cache.position.marginToken,\n (-cache.recordPnlToken).toUint256()\n );\n VaultProcess.transferOut(\n portfolioVault,\n cache.position.marginToken,\n cache.stakeToken,\n (-cache.recordPnlToken).toUint256() - addLiability,\n true\n );\n }\n if (!cache.isLiquidation) {\n int256 changeToken = (\n cache.decreaseMarginInUsdFromBalance.mul(cache.position.initialMargin).div(\n cache.position.initialMarginInUsd\n )\n ).toInt256() +\n cache.settledMargin -\n cache.decreaseMargin.toInt256();\n updatePositionFromBalanceMargin(position, changeToken);\n }\n } else {\n if (cache.isLiquidation) {\n return 0;\n }\n if (cache.recordPnlToken < 0 || (cache.recordPnlToken >= 0 && cache.position.isLong)) {\n VaultProcess.transferOut(\n cache.stakeToken,\n cache.position.marginToken,\n accountProps.owner,\n cache.settledMargin.toUint256(),\n true\n );\n } else {\n VaultProcess.transferOut(\n CommonData.getStakeUsdToken(),\n cache.position.marginToken,\n cache.stakeToken,\n cache.recordPnlToken.toUint256() + cache.closeFee,\n true\n );\n VaultProcess.transferOut(\n cache.stakeToken,\n cache.position.marginToken,\n accountProps.owner,\n cache.settledMargin.toUint256(),\n true\n );\n }\n }\n }\n\n function updatePositionFromBalanceMargin(\n Position.Props storage position,\n int256 amount\n ) public returns (uint256 addAmount) {\n if (position.initialMarginInUsd == position.initialMarginInUsdFromBalance || amount == 0) {\n addAmount = 0;\n return 0;\n }\n if (amount > 0) {\n uint256 borrowMargin = (position.initialMarginInUsd - position.initialMarginInUsdFromBalance)\n .mul(position.initialMargin)\n .div(position.initialMarginInUsd);\n addAmount = amount.toUint256().min(borrowMargin);\n position.initialMarginInUsdFromBalance += addAmount.mul(position.initialMarginInUsd).div(\n position.initialMargin\n );\n } else {\n uint256 addBorrowMarginInUsd = (-amount).toUint256().mul(position.initialMarginInUsd).div(\n position.initialMargin\n );\n position.initialMarginInUsdFromBalance = position.initialMarginInUsdFromBalance <= addBorrowMarginInUsd\n ? 0\n : position.initialMarginInUsdFromBalance - addBorrowMarginInUsd;\n }\n }\n\n function _getPosFee(DecreasePositionCache memory cache) internal pure returns (int256) {\n return\n cache.closeFeeInUsd.toInt256() + cache.settledBorrowingFeeInUsd.toInt256() + cache.settledFundingFeeInUsd;\n }\n}\n" + }, + "contracts/process/FeeProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/IFee.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/FeeRewards.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"./MarketProcess.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary FeeProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedMath for int256;\n using SignedSafeMath for int256;\n using SafeERC20 for IERC20;\n using Config for Config.Props;\n using Position for Position.Props;\n using UsdPool for UsdPool.Props;\n using LpPool for LpPool.Props;\n using StakingAccount for StakingAccount.Props;\n using FeeRewards for FeeRewards.MarketRewards;\n using FeeRewards for FeeRewards.StakingRewards;\n\n bytes32 public constant FEE_MINT = keccak256(abi.encode(\"FEE_MINT\"));\n\n bytes32 public constant FEE_REDEEM = keccak256(abi.encode(\"FEE_REDEEM\"));\n\n bytes32 public constant FEE_OPEN_POSITION = keccak256(abi.encode(\"FEE_OPEN_POSITION\"));\n\n bytes32 public constant FEE_CLOSE_POSITION = keccak256(abi.encode(\"FEE_CLOSE_POSITION\"));\n\n bytes32 public constant FEE_LIQUIDATION = keccak256(abi.encode(\"FEE_LIQUIDATION\"));\n\n bytes32 public constant FEE_BORROWING = keccak256(abi.encode(\"FEE_BORROWING\"));\n\n bytes32 public constant FEE_FUNDING = keccak256(abi.encode(\"FEE_FUNDING\"));\n\n struct ChargeMintOrRedeemFeeEventParams {\n address stakeToken;\n address feeToken;\n address account;\n bytes32 feeType;\n uint256 fee;\n }\n\n struct ChargeFeeCache {\n uint256 ratioToStakingRewards;\n uint256 ratioToPoolRewards;\n uint256 feeToStakingRewards;\n uint256 feeToMarketRewards;\n uint256 feeToPoolRewards;\n uint256 feeToDaoRewards;\n address stakeToken;\n }\n\n event ChargeTradingFeeEvent(bytes32 positionKey, bytes32 symbol, bytes32 feeType, uint256 fee);\n\n event ChargeMintOrRedeemFeeEvent(ChargeMintOrRedeemFeeEventParams params);\n\n event ChargeBorrowingFeeEvent(\n bool isCrossMargin,\n address stakeToken,\n address token,\n address account,\n bytes32 feeType,\n uint256 fee\n );\n\n function updateBorrowingFee(Position.Props storage position, address stakeToken) public {\n uint256 cumulativeBorrowingFeePerToken = MarketQueryProcess.getCumulativeBorrowingFeePerToken(\n stakeToken,\n position.isLong,\n position.marginToken\n );\n uint256 realizedBorrowingFeeDelta = CalUtils.mulSmallRate(\n CalUtils.mulRate(position.initialMargin, position.leverage - CalUtils.RATE_PRECISION),\n cumulativeBorrowingFeePerToken - position.positionFee.openBorrowingFeePerToken\n );\n position.positionFee.realizedBorrowingFee += realizedBorrowingFeeDelta;\n position.positionFee.realizedBorrowingFeeInUsd += CalUtils.tokenToUsd(\n realizedBorrowingFeeDelta,\n TokenUtils.decimals(position.marginToken),\n OracleProcess.getLatestUsdUintPrice(position.marginToken, position.isLong)\n );\n position.positionFee.openBorrowingFeePerToken = cumulativeBorrowingFeePerToken;\n MarketProcess.updateTotalBorrowingFee(\n stakeToken,\n position.isLong,\n position.marginToken,\n 0,\n realizedBorrowingFeeDelta.toInt256()\n );\n }\n\n function updateFundingFee(Position.Props storage position) public {\n int256 fundingFeePerQty = MarketQueryProcess.getFundingFeePerQty(position.symbol, position.isLong);\n int256 realizedFundingFeeDelta = CalUtils.mulIntSmallRate(\n position.qty.toInt256(),\n (fundingFeePerQty - position.positionFee.openFundingFeePerQty)\n );\n if (position.isLong) {\n position.positionFee.realizedFundingFee += realizedFundingFeeDelta;\n position.positionFee.realizedFundingFeeInUsd += CalUtils.tokenToUsdInt(\n realizedFundingFeeDelta,\n TokenUtils.decimals(position.marginToken),\n OracleProcess.getLatestUsdPrice(position.marginToken, position.isLong)\n );\n } else {\n position.positionFee.realizedFundingFeeInUsd += realizedFundingFeeDelta;\n position.positionFee.realizedFundingFee += CalUtils.usdToTokenInt(\n realizedFundingFeeDelta,\n TokenUtils.decimals(position.marginToken),\n OracleProcess.getLatestUsdPrice(position.marginToken, position.isLong)\n );\n }\n consoleInt(\"position.positionFee.realizedFundingFee\", position.positionFee.realizedFundingFee);\n consoleInt(\"position.positionFee.realizedFundingFeeInUsd\", position.positionFee.realizedFundingFeeInUsd);\n position.positionFee.openFundingFeePerQty = fundingFeePerQty;\n MarketProcess.updateMarketFundingFee(\n position.symbol,\n realizedFundingFeeDelta,\n position.isLong,\n true,\n position.marginToken\n );\n }\n\n function consoleInt(string memory code, int256 value) internal pure {\n if (value > 0) {\n console.log(code, value.toUint256());\n } else {\n console.log(\"-\", code, (-value).toUint256());\n }\n }\n\n function chargeTradingFee(\n uint256 fee,\n bytes32 symbol,\n bytes32 feeType,\n address feeToken,\n Position.Props memory position\n ) internal {\n FeeRewards.StakingRewards storage stakingRewardsProps = FeeRewards.loadStakingRewards();\n FeeRewards.MarketRewards storage marketTradingRewardsProps = FeeRewards.loadMarketTradingRewards(symbol);\n FeeRewards.StakingRewards storage daoRewardsProps = FeeRewards.loadDaoRewards();\n Config.Props storage configProps = Config.load();\n ChargeFeeCache memory cache;\n cache.stakeToken = Symbol.load(symbol).stakeToken;\n cache.feeToStakingRewards = CalUtils.mulRate(fee, configProps.tradeConfig.tradingFeeStakingRewardsRatio);\n cache.feeToMarketRewards = CalUtils.mulRate(fee, configProps.tradeConfig.tradingFeePoolRewardsRatio);\n cache.feeToDaoRewards = fee.sub(cache.feeToStakingRewards).sub(cache.feeToMarketRewards);\n\n marketTradingRewardsProps.addFeeAmount(feeToken, cache.feeToMarketRewards);\n stakingRewardsProps.addFeeAmount(cache.stakeToken, feeToken, cache.feeToStakingRewards);\n daoRewardsProps.addFeeAmount(cache.stakeToken, feeToken, cache.feeToDaoRewards);\n if (position.isCrossMargin) {\n marketTradingRewardsProps.addUnsettleFeeAmount(feeToken, cache.feeToPoolRewards);\n stakingRewardsProps.addUnsettleFeeAmount(cache.stakeToken, feeToken, cache.feeToStakingRewards);\n daoRewardsProps.addUnsettleFeeAmount(cache.stakeToken, feeToken, cache.feeToDaoRewards);\n }\n emit ChargeTradingFeeEvent(position.key, symbol, feeType, fee);\n }\n\n function chargeMintOrRedeemFee(\n uint256 fee,\n address stakeToken,\n address feeToken,\n address account,\n bytes32 feeType,\n bool isCollateral\n ) public {\n ChargeFeeCache memory cache;\n Config.Props storage configProps = Config.load();\n if (feeType == FEE_MINT) {\n cache.ratioToStakingRewards = configProps.stakeConfig.mintFeeStakingRewardsRatio;\n cache.ratioToPoolRewards = configProps.stakeConfig.mintFeePoolRewardsRatio;\n } else if (feeType == FEE_REDEEM) {\n cache.ratioToStakingRewards = configProps.stakeConfig.redeemFeeStakingRewardsRatio;\n cache.ratioToPoolRewards = configProps.stakeConfig.redeemFeePoolRewardsRatio;\n }\n cache.feeToStakingRewards = CalUtils.mulRate(fee, cache.ratioToStakingRewards);\n cache.feeToPoolRewards = CalUtils.mulRate(fee, cache.ratioToPoolRewards);\n cache.feeToDaoRewards = fee.sub(cache.feeToStakingRewards).sub(cache.feeToPoolRewards);\n FeeRewards.StakingRewards storage stakingRewardsProps = FeeRewards.loadStakingRewards();\n FeeRewards.MarketRewards storage poolRewardsProps = FeeRewards.loadPoolRewards(stakeToken);\n FeeRewards.StakingRewards storage daoRewardsProps = FeeRewards.loadDaoRewards();\n if (isCollateral) {\n stakingRewardsProps.addCollateralFeeAmount(stakeToken, feeToken, cache.feeToStakingRewards);\n poolRewardsProps.addCollateralFeeAmount(feeToken, cache.feeToPoolRewards);\n daoRewardsProps.addCollateralFeeAmount(stakeToken, feeToken, cache.feeToDaoRewards);\n } else {\n stakingRewardsProps.addFeeAmount(stakeToken, feeToken, cache.feeToStakingRewards);\n poolRewardsProps.addFeeAmount(feeToken, cache.feeToPoolRewards);\n daoRewardsProps.addFeeAmount(stakeToken, feeToken, cache.feeToDaoRewards);\n }\n\n ChargeMintOrRedeemFeeEventParams memory params = ChargeMintOrRedeemFeeEventParams({\n stakeToken: stakeToken,\n feeToken: feeToken,\n account: account,\n feeType: feeType,\n fee: fee\n });\n\n emit ChargeMintOrRedeemFeeEvent(params);\n }\n\n function chargeBorrowingFee(\n bool isCrossMargin,\n uint256 fee,\n address stakeToken,\n address feeToken,\n address account,\n bytes32 feeType\n ) public {\n FeeRewards.StakingRewards storage stakingRewardsProps = FeeRewards.loadStakingRewards();\n FeeRewards.MarketRewards storage poolRewardsProps = FeeRewards.loadPoolRewards(stakeToken);\n FeeRewards.StakingRewards storage daoRewardsProps = FeeRewards.loadDaoRewards();\n\n Config.Props storage configProps = Config.load();\n ChargeFeeCache memory cache;\n cache.feeToStakingRewards = CalUtils.mulRate(fee, configProps.tradeConfig.borrowingFeeStakingRewardsRatio);\n cache.feeToPoolRewards = CalUtils.mulRate(fee, configProps.tradeConfig.borrowingFeePoolRewardsRatio);\n cache.feeToDaoRewards = fee.sub(cache.feeToStakingRewards).sub(cache.feeToPoolRewards);\n\n stakingRewardsProps.addFeeAmount(stakeToken, feeToken, cache.feeToStakingRewards);\n poolRewardsProps.addFeeAmount(feeToken, cache.feeToPoolRewards);\n daoRewardsProps.addFeeAmount(stakeToken, feeToken, cache.feeToDaoRewards);\n\n if (isCrossMargin) {\n stakingRewardsProps.addUnsettleFeeAmount(stakeToken, feeToken, cache.feeToStakingRewards);\n poolRewardsProps.addUnsettleFeeAmount(feeToken, cache.feeToPoolRewards);\n daoRewardsProps.addUnsettleFeeAmount(stakeToken, feeToken, cache.feeToDaoRewards);\n }\n\n emit ChargeBorrowingFeeEvent(isCrossMargin, stakeToken, feeToken, account, feeType, fee);\n }\n}\n" + }, + "contracts/process/FeeQueryProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../interfaces/IFee.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/FeeRewards.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../utils/CalUtils.sol\";\n\nlibrary FeeQueryProcess {\n using SafeERC20 for IERC20;\n using Config for Config.Props;\n using SafeMath for uint256;\n using SafeCast for uint256;\n using FeeRewards for FeeRewards.MarketRewards;\n using FeeRewards for FeeRewards.StakingRewards;\n using StakingAccount for StakingAccount.Props;\n\n\n function calcOpenFee(uint256 orderMargin, uint256 leverage, bytes32 symbol) public view returns (uint256) {\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(symbol);\n uint256 leverageMargin = CalUtils.mulRate(orderMargin, leverage);\n return CalUtils.mulRate(leverageMargin, symbolConfig.openFeeRate);\n }\n\n function calcCloseFee(uint8 tokenDecimals, uint256 feeInUsd, uint256 tokenPrice) public pure returns (uint256) {\n return CalUtils.usdToToken(feeInUsd, tokenDecimals, tokenPrice);\n }\n\n function calcMintOrRedeemFee(uint256 tokenAmount, uint256 feeRate) public pure returns (uint256) {\n return CalUtils.mulRate(tokenAmount, feeRate);\n }\n\n function calcBorrowingFee(\n uint256 decreaseQty,\n Position.Props memory position\n ) public pure returns (uint256 fee, uint256 feeInUsd) {\n if (decreaseQty == position.qty) {\n return (position.positionFee.realizedBorrowingFee, position.positionFee.realizedBorrowingFeeInUsd);\n }\n return (\n position.positionFee.realizedBorrowingFee.mul(decreaseQty).div(position.qty),\n position.positionFee.realizedBorrowingFeeInUsd.mul(decreaseQty).div(position.qty)\n );\n }\n\n function getPoolTokenFeeAmount(address stakeToken, address token) external view returns (uint256) {\n FeeRewards.MarketRewards storage poolRewardsProps = FeeRewards.loadPoolRewards(stakeToken);\n return poolRewardsProps.getFeeAmount(token);\n }\n\n function getCumulativeRewardsPerStakeToken(address stakeToken) external view returns (uint256) {\n FeeRewards.MarketRewards storage poolRewardsProps = FeeRewards.loadPoolRewards(stakeToken);\n return poolRewardsProps.getCumulativeRewardsPerStakeToken();\n }\n\n function getMarketTokenFeeAmount(bytes32 symbol, address token) external view returns (uint256) {\n FeeRewards.MarketRewards storage marketTradingRewardsProps = FeeRewards.loadMarketTradingRewards(symbol);\n return marketTradingRewardsProps.getFeeAmount(token);\n }\n\n function getStakingTokenFee(address stakeToken, address token) external view returns(uint256) {\n FeeRewards.StakingRewards storage stakingRewards = FeeRewards.loadStakingRewards();\n return stakingRewards.getFeeAmount(stakeToken, token);\n }\n\n function getDaoTokenFee(address stakeToken, address token) external view returns(uint256) {\n FeeRewards.StakingRewards storage daoRewards = FeeRewards.loadDaoRewards();\n return daoRewards.getFeeAmount(stakeToken, token);\n }\n\n function getAccountFeeRewards(address account) external view returns(IFee.AccountFeeRewards[] memory) {\n StakingAccount.Props storage stakingAccount = StakingAccount.load(account);\n address[] memory stakeTokens = stakingAccount.getStakeTokens();\n IFee.AccountFeeRewards[] memory rewards = new IFee.AccountFeeRewards[](stakeTokens.length);\n for (uint256 i; i < stakeTokens.length; i++) {\n FeeRewards.MarketRewards storage feeProps = FeeRewards.loadPoolRewards(stakeTokens[i]);\n StakingAccount.FeeRewards storage accountFeeRewards = stakingAccount.getFeeRewards(stakeTokens[i]);\n rewards[i].stakeToken = stakeTokens[i];\n if (CommonData.getStakeUsdToken() != stakeTokens[i]) {\n LpPool.Props storage pool = LpPool.load(stakeTokens[i]);\n rewards[i].token = pool.baseToken;\n }\n uint256 accountStakeTokens = IERC20(stakeTokens[i]).balanceOf(account);\n if (\n accountFeeRewards.openRewardsPerStakeToken > 0 &&\n feeProps.getCumulativeRewardsPerStakeToken() - accountFeeRewards.openRewardsPerStakeToken >\n feeProps.getPoolRewardsPerStakeTokenDeltaLimit()\n ) {\n rewards[i].rewards = CalUtils.mulSmallRate(\n feeProps.getCumulativeRewardsPerStakeToken() - accountFeeRewards.openRewardsPerStakeToken,\n accountStakeTokens\n );\n }\n }\n return rewards;\n }\n}\n" + }, + "contracts/process/FeeRewardsProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/IFee.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/FeeRewards.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/ClaimRewards.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"./VaultProcess.sol\";\nimport \"./LpPoolQueryProcess.sol\";\nimport \"./GasProcess.sol\";\nimport \"./AssetsProcess.sol\";\n\nlibrary FeeRewardsProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeERC20 for IERC20;\n using Config for Config.Props;\n using UsdPool for UsdPool.Props;\n using LpPool for LpPool.Props;\n using LpPoolQueryProcess for LpPool.Props;\n using LpPoolQueryProcess for UsdPool.Props;\n using StakingAccount for StakingAccount.Props;\n using FeeRewards for FeeRewards.MarketRewards;\n using FeeRewards for FeeRewards.StakingRewards;\n\n struct TidyTradingRewardsCache {\n uint256 totalFeeValueInUsd;\n uint256 usdPoolShouldTakeInUsd;\n address maxAmountStableToken;\n uint256 usdTokenNeedAmount;\n uint256 baseTokenSwapAmount;\n }\n\n function distributeFeeRewards(uint256 interval) external {\n bytes32[] memory symbols = CommonData.getAllSymbols();\n address[] memory stakeTokens = new address[](symbols.length);\n _updateStableTokenRewardsToUsdPool();\n for (uint256 i; i < symbols.length; i++) {\n stakeTokens[i] = Symbol.load(symbols[i]).stakeToken;\n _tidyUnsettleRewards(FeeRewards.loadMarketTradingRewards(symbols[i]), stakeTokens[i]);\n _tidyUnsettleRewards(FeeRewards.loadPoolRewards(stakeTokens[i]), stakeTokens[i]);\n _updateBaseTokenRewardsToLpPool(LpPool.load(stakeTokens[i]));\n _tidyTradingRewards(symbols[i], stakeTokens[i]);\n _tidyMintAndRedeemRewards(stakeTokens[i]);\n _updatePoolApr(stakeTokens[i], interval);\n }\n _tidyUnsettleRewards(FeeRewards.loadPoolRewards(CommonData.getStakeUsdToken()), CommonData.getStakeUsdToken());\n _updatePoolApr(CommonData.getStakeUsdToken(), interval);\n for (uint256 i; i < stakeTokens.length; i++) {\n _distributePoolRewards(stakeTokens[i]);\n }\n _distributeUsdPoolRewards();\n }\n\n function updateAccountFeeRewards(address account, address stakeToken) public {\n StakingAccount.FeeRewards storage accountFeeRewards = StakingAccount.load(account).getFeeRewards(stakeToken);\n FeeRewards.MarketRewards storage feeProps = FeeRewards.loadPoolRewards(stakeToken);\n uint256 stakeTokens = IERC20(stakeToken).balanceOf(account);\n if (\n stakeTokens > 0 &&\n accountFeeRewards.openRewardsPerStakeToken >= 0 &&\n feeProps.getCumulativeRewardsPerStakeToken() - accountFeeRewards.openRewardsPerStakeToken >\n feeProps.getPoolRewardsPerStakeTokenDeltaLimit()\n ) {\n accountFeeRewards.realisedRewardsTokenAmount += CalUtils.mulSmallRate(\n feeProps.getCumulativeRewardsPerStakeToken() - accountFeeRewards.openRewardsPerStakeToken,\n stakeTokens\n );\n }\n if (stakeTokens > 0) {\n accountFeeRewards.openRewardsPerStakeToken = feeProps.getCumulativeRewardsPerStakeToken();\n } else {\n accountFeeRewards.openRewardsPerStakeToken = 0;\n }\n }\n\n function _tidyUnsettleRewards(FeeRewards.MarketRewards storage marketRewards, address stakeToken) internal {\n address[] memory tokens = marketRewards.getFeeTokens();\n for (uint256 i; i < tokens.length; i++) {\n uint256 unsettleAmount = marketRewards.getUnsettleFeeAmount(tokens[i]);\n if (unsettleAmount == 0) {\n continue;\n }\n bool transferSuccess = VaultProcess.transferOut(\n IVault(address(this)).getPortfolioVaultAddress(),\n tokens[i],\n stakeToken,\n unsettleAmount\n );\n if (transferSuccess) {\n marketRewards.subUnsettleFeeAmount(tokens[i], unsettleAmount);\n }\n }\n }\n\n function _tidyTradingRewards(bytes32 symbol, address stakeToken) internal {\n FeeRewards.MarketRewards storage marketTradingRewardsProps = FeeRewards.loadMarketTradingRewards(symbol);\n TidyTradingRewardsCache memory tidyCache;\n tidyCache.totalFeeValueInUsd = _getTotalFeeValueInUsd(marketTradingRewardsProps);\n if (tidyCache.totalFeeValueInUsd == 0) {\n return;\n }\n Config.Props storage config = Config.load();\n tidyCache.usdPoolShouldTakeInUsd = CalUtils.mulRate(\n tidyCache.totalFeeValueInUsd,\n config.tradeConfig.tradingFeeUsdPoolRewardsRatio\n );\n UsdPool.Props storage usdPool = UsdPool.load();\n address[] memory stableTokens = usdPool.getStableTokens();\n FeeRewards.MarketRewards storage usdPoolRewards = FeeRewards.loadPoolRewards(CommonData.getStakeUsdToken());\n for (uint256 i; i < stableTokens.length; i++) {\n uint256 transferTokenAmount = marketTradingRewardsProps.getFeeAmount(stableTokens[i]);\n if (transferTokenAmount == 0) {\n continue;\n }\n uint256 usdToken = CalUtils.usdToToken(\n tidyCache.usdPoolShouldTakeInUsd,\n TokenUtils.decimals(stableTokens[i]),\n OracleProcess.getLatestUsdUintPrice(stableTokens[i], true)\n );\n if (transferTokenAmount < usdToken) {\n tidyCache.usdPoolShouldTakeInUsd -= CalUtils.tokenToUsd(\n transferTokenAmount,\n TokenUtils.decimals(stableTokens[i]),\n OracleProcess.getLatestUsdUintPrice(stableTokens[i], true)\n );\n } else {\n transferTokenAmount = usdToken;\n tidyCache.usdPoolShouldTakeInUsd = 0;\n }\n usdPool.addStableToken(stableTokens[i], transferTokenAmount);\n usdPoolRewards.addFeeAmount(stableTokens[i], transferTokenAmount);\n marketTradingRewardsProps.subFeeAmount(stableTokens[i], transferTokenAmount);\n\n if (tidyCache.usdPoolShouldTakeInUsd == 0) {\n break;\n }\n }\n LpPool.Props storage lpPoolProps = LpPool.load(stakeToken);\n if (tidyCache.usdPoolShouldTakeInUsd > 0) {\n tidyCache.maxAmountStableToken = usdPool.getMaxAmountStableToken();\n tidyCache.usdTokenNeedAmount = CalUtils.usdToToken(\n tidyCache.usdPoolShouldTakeInUsd,\n TokenUtils.decimals(tidyCache.maxAmountStableToken),\n OracleProcess.getLatestUsdUintPrice(tidyCache.maxAmountStableToken, false)\n );\n tidyCache.baseTokenSwapAmount = CalUtils.usdToToken(\n tidyCache.usdPoolShouldTakeInUsd,\n TokenUtils.decimals(lpPoolProps.baseToken),\n OracleProcess.getLatestUsdUintPrice(lpPoolProps.baseToken, true)\n );\n tidyCache.baseTokenSwapAmount += CalUtils.mulRate(\n tidyCache.baseTokenSwapAmount,\n config.tradeConfig.swapSlipperTokenFactor\n );\n usdPool.addUnsettleStableToken(tidyCache.maxAmountStableToken, tidyCache.usdTokenNeedAmount);\n lpPoolProps.addLossStableToken(tidyCache.maxAmountStableToken, tidyCache.usdTokenNeedAmount);\n lpPoolProps.addBaseToken(tidyCache.baseTokenSwapAmount);\n marketTradingRewardsProps.subFeeAmount(lpPoolProps.baseToken, tidyCache.baseTokenSwapAmount);\n usdPoolRewards.addFeeAmount(tidyCache.maxAmountStableToken, tidyCache.usdTokenNeedAmount);\n }\n _updateLpPoolTradingRewards(marketTradingRewardsProps, lpPoolProps, config, stableTokens);\n }\n\n function _tidyMintAndRedeemRewards(address stakeToken) internal {\n LpPool.Props storage lpPoolProps = LpPool.load(stakeToken);\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(lpPoolProps.stakeToken);\n address[] memory collateralTokens = poolRewards.getCollateralFeeTokens();\n for (uint256 i; i < collateralTokens.length; i++) {\n uint256 collateralFeeAmount = poolRewards.getCollateralFeeAmount(collateralTokens[i]);\n if (collateralFeeAmount == 0) {\n continue;\n }\n Config.StakeCollateralConfig memory collateralConfig = lpPoolProps.getStakeCollateralConfig(\n collateralTokens[i]\n );\n uint256 toBaseTokenAmount = CalUtils.mulRate(collateralFeeAmount, collateralConfig.discount);\n lpPoolProps.addCollateralBaseToken(toBaseTokenAmount, collateralTokens[i], collateralFeeAmount);\n lpPoolProps.subBaseToken(toBaseTokenAmount);\n poolRewards.subCollateralFeeAmount(collateralTokens[i], collateralFeeAmount);\n poolRewards.addFeeAmount(lpPoolProps.baseToken, toBaseTokenAmount);\n }\n }\n\n function _updatePoolApr(address stakeToken, uint256 interval) internal {\n if (stakeToken == CommonData.getStakeUsdToken()) {\n UsdPool.Props storage pool = UsdPool.load();\n uint256 poolValue = pool.getUsdPoolValue();\n if (poolValue == 0) {\n return;\n }\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(stakeToken);\n uint256 feeValue = _getTotalFeeValueInUsd(poolRewards);\n pool.apr = feeValue.mul(24 * 60 * 365 * CalUtils.RATE_PRECISION).div(poolValue).div(interval);\n } else {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n uint256 poolValue = pool.getPoolValue();\n if (poolValue == 0) {\n return;\n }\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(stakeToken);\n uint256 feeValue = CalUtils.tokenToUsd(\n poolRewards.getFeeAmount(pool.baseToken),\n TokenUtils.decimals(pool.baseToken),\n OracleProcess.getLatestUsdUintPrice(pool.baseToken, false)\n );\n pool.apr = feeValue.mul(24 * 60 * 365 * CalUtils.RATE_PRECISION).div(poolValue).div(interval);\n }\n }\n\n function _distributePoolRewards(address stakeToken) internal {\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(stakeToken);\n LpPool.Props storage pool = LpPool.load(stakeToken);\n uint256 feeAmount = poolRewards.getFeeAmount(pool.baseToken);\n if (feeAmount == 0) {\n return;\n }\n uint256 totalSupply = TokenUtils.totalSupply(stakeToken);\n if (totalSupply == 0) {\n return;\n }\n uint256 poolRewardsPerStakeTokenDelta = CalUtils.divSmallRate(feeAmount, totalSupply);\n poolRewards.cumulativeRewardsPerStakeToken += poolRewardsPerStakeTokenDelta;\n poolRewards.setFeeAmountZero(pool.baseToken);\n poolRewards.addLastRewardsPerStakeTokenDelta(\n poolRewardsPerStakeTokenDelta,\n Config.load().getStakeConfig().poolRewardsIntervalLimit\n );\n }\n\n function _distributeUsdPoolRewards() internal {\n address stakeToken = CommonData.getStakeUsdToken();\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(stakeToken);\n address[] memory feeTokens = poolRewards.getFeeTokens();\n if (feeTokens.length == 0) {\n return;\n }\n uint256 totalSupply = TokenUtils.totalSupply(stakeToken);\n if (totalSupply == 0) {\n return;\n }\n uint256 totalValue = _getTotalFeeValueInUsd(poolRewards);\n if (totalValue == 0) {\n return;\n }\n uint256 poolRewardsPerStakeTokenDelta = CalUtils.divSmallRate(totalValue, totalSupply);\n poolRewards.cumulativeRewardsPerStakeToken += poolRewardsPerStakeTokenDelta;\n poolRewards.addLastRewardsPerStakeTokenDelta(\n poolRewardsPerStakeTokenDelta,\n Config.load().getStakeConfig().poolRewardsIntervalLimit\n );\n for (uint256 i; i < feeTokens.length; i++) {\n poolRewards.setFeeAmountZero(feeTokens[i]);\n }\n }\n\n function _updateLpPoolTradingRewards(\n FeeRewards.MarketRewards storage marketTradingRewardsProps,\n LpPool.Props storage lpPoolProps,\n Config.Props storage config,\n address[] memory stableTokens\n ) internal {\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(lpPoolProps.stakeToken);\n uint256 feeAmount = marketTradingRewardsProps.getFeeAmount(lpPoolProps.baseToken);\n if (feeAmount > 0) {\n lpPoolProps.addBaseToken(feeAmount);\n poolRewards.addFeeAmount(lpPoolProps.baseToken, feeAmount);\n marketTradingRewardsProps.subFeeAmount(lpPoolProps.baseToken, feeAmount);\n }\n uint8 baseTokenDecimals = TokenUtils.decimals(lpPoolProps.baseToken);\n uint256 baseTokenPrice = OracleProcess.getLatestUsdUintPrice(lpPoolProps.baseToken, false);\n for (uint256 i; i < stableTokens.length; i++) {\n feeAmount = marketTradingRewardsProps.getFeeAmount(stableTokens[i]);\n if (feeAmount == 0) {\n continue;\n }\n uint256 toBaseTokenAmount = CalUtils.tokenToToken(\n feeAmount,\n TokenUtils.decimals(stableTokens[i]),\n baseTokenDecimals,\n OracleProcess.getLatestUsdUintPrice(stableTokens[i], true),\n baseTokenPrice\n );\n toBaseTokenAmount -= CalUtils.mulRate(toBaseTokenAmount, config.tradeConfig.swapSlipperTokenFactor);\n lpPoolProps.addStableToken(stableTokens[i], feeAmount);\n marketTradingRewardsProps.setFeeAmountZero(stableTokens[i]);\n poolRewards.addFeeAmount(lpPoolProps.baseToken, toBaseTokenAmount);\n }\n }\n\n function _updateBaseTokenRewardsToLpPool(LpPool.Props storage lpPoolProps) internal {\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(lpPoolProps.stakeToken);\n uint256 baseTokenUnsettleFeeAmount = poolRewards.getUnsettleFeeAmount(lpPoolProps.baseToken);\n if (baseTokenUnsettleFeeAmount > 0) {\n lpPoolProps.addUnsettleBaseToken(baseTokenUnsettleFeeAmount.toInt256());\n }\n uint256 baseTokenFeeAmount = poolRewards.getFeeAmount(lpPoolProps.baseToken);\n if (baseTokenFeeAmount > 0) {\n lpPoolProps.addBaseToken(baseTokenFeeAmount - baseTokenUnsettleFeeAmount);\n }\n address[] memory collateralTokens = poolRewards.getCollateralFeeTokens();\n for (uint256 i; i < collateralTokens.length; i++) {\n uint256 collateralFeeAmount = poolRewards.getCollateralFeeAmount(collateralTokens[i]);\n if (collateralFeeAmount > 0) {\n Config.StakeCollateralConfig memory collateralConfig = lpPoolProps.getStakeCollateralConfig(\n collateralTokens[i]\n );\n uint256 collateralToBaseTokenAmount = CalUtils.mulRate(collateralFeeAmount, collateralConfig.discount);\n lpPoolProps.addCollateralBaseToken(\n collateralToBaseTokenAmount,\n collateralTokens[i],\n collateralFeeAmount\n );\n }\n }\n }\n\n function _updateStableTokenRewardsToUsdPool() internal {\n UsdPool.Props storage usdPool = UsdPool.load();\n FeeRewards.MarketRewards storage poolRewards = FeeRewards.loadPoolRewards(CommonData.getStakeUsdToken());\n address[] memory stableTokens = usdPool.getStableTokens();\n for (uint256 i; i < stableTokens.length; i++) {\n uint256 unsettleFeeAmount = poolRewards.getUnsettleFeeAmount(stableTokens[i]);\n if (unsettleFeeAmount > 0) {\n usdPool.addUnsettleStableToken(stableTokens[i], unsettleFeeAmount);\n }\n uint256 feeAmount = poolRewards.getFeeAmount(stableTokens[i]);\n if (feeAmount > 0) {\n usdPool.addStableToken(stableTokens[i], feeAmount - unsettleFeeAmount);\n }\n }\n }\n\n function _getTotalFeeValueInUsd(FeeRewards.MarketRewards storage feeProps) internal view returns (uint256) {\n uint256 totalFeeValue;\n address[] memory allTokens = feeProps.getFeeTokens();\n for (uint256 i; i < allTokens.length; i++) {\n uint256 tokenValue = CalUtils.tokenToUsd(\n feeProps.getFeeAmount(allTokens[i]),\n TokenUtils.decimals(allTokens[i]),\n OracleProcess.getLatestUsdUintPrice(allTokens[i], true)\n );\n totalFeeValue += tokenValue;\n }\n return totalFeeValue;\n }\n}\n" + }, + "contracts/process/GasProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\nimport \"./VaultProcess.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary GasProcess {\n struct PayExecutionFeeParams {\n address from;\n uint256 userExecutionFee;\n uint256 startGas;\n address keeper;\n address account;\n }\n\n function processExecutionFee(PayExecutionFeeParams memory cache) external {\n uint256 usedGas = cache.startGas - gasleft() / 63 - gasleft();\n uint256 executionFee = usedGas * tx.gasprice;\n uint256 refundFee;\n uint256 lossFee;\n if (executionFee > cache.userExecutionFee) {\n executionFee = cache.userExecutionFee;\n lossFee = executionFee - cache.userExecutionFee;\n } else {\n refundFee = cache.userExecutionFee - executionFee;\n }\n VaultProcess.transferOut(cache.from, Config.getWrapperToken(), address(this), cache.userExecutionFee);\n VaultProcess.withdrawEther(cache.keeper, executionFee);\n if (refundFee > 0) {\n VaultProcess.withdrawEther(cache.account, refundFee);\n }\n if (lossFee > 0) {\n CommonData.addLossExecutionFee(lossFee);\n }\n }\n\n function addLossExecutionFee(uint256 startGas) external {\n uint256 usedGas = startGas - gasleft() / 63 - gasleft();\n uint256 executionFee = usedGas * tx.gasprice;\n if (executionFee > 0) {\n CommonData.addLossExecutionFee(executionFee);\n }\n }\n\n function validateExecutionFeeLimit(uint256 executionFee, uint256 gasLimit) external view {\n if (executionFee < gasLimit * tx.gasprice) {\n console.log(\"gasPrice\", tx.gasprice, \"executionFee\", executionFee);\n revert Errors.ExecutionFeeNotEnough();\n }\n }\n}\n" + }, + "contracts/process/IncreasePositionProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/Order.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/Account.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"./MarketProcess.sol\";\nimport \"./LpPoolProcess.sol\";\nimport \"./FeeProcess.sol\";\nimport \"./AccountProcess.sol\";\nimport \"./FeeQueryProcess.sol\";\n\nlibrary IncreasePositionProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedSafeMath for int256;\n using Math for uint256;\n using Config for Config.Props;\n using Position for Position.Props;\n using Order for Order.Props;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n\n struct IncreasePositionParams {\n uint256 requestId;\n address marginToken;\n uint256 increaseMargin;\n uint256 increaseMarginFromBalance;\n uint256 marginTokenPrice;\n uint256 indexTokenPrice;\n uint256 leverage;\n bool isLong;\n bool isCrossMargin;\n }\n\n function increasePosition(\n Position.Props storage position,\n Symbol.Props memory symbolProps,\n IncreasePositionParams calldata params\n ) external {\n uint256 fee = FeeQueryProcess.calcOpenFee(params.increaseMargin, params.leverage, symbolProps.code);\n FeeProcess.chargeTradingFee(fee, symbolProps.code, FeeProcess.FEE_OPEN_POSITION, params.marginToken, position);\n if (params.isCrossMargin) {\n Account.Props storage accountProps = Account.load(position.account);\n accountProps.unUseToken(params.marginToken, fee);\n accountProps.subTokenWithLiability(params.marginToken, fee);\n }\n\n uint256 increaseMargin = params.increaseMargin - fee;\n uint256 increaseMarginFromBalance = params.increaseMarginFromBalance > fee\n ? params.increaseMarginFromBalance - fee\n : 0;\n\n uint8 tokenDecimals = TokenUtils.decimals(params.marginToken);\n uint256 increaseQty = CalUtils.tokenToUsd(\n CalUtils.mulRate(increaseMargin, params.leverage),\n tokenDecimals,\n params.marginTokenPrice\n );\n\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(symbolProps.code);\n if (position.qty == 0) {\n position.marginToken = params.marginToken;\n position.entryPrice = params.indexTokenPrice;\n position.initialMargin = increaseMargin;\n position.initialMarginInUsd = CalUtils.tokenToUsd(increaseMargin, tokenDecimals, params.marginTokenPrice);\n position.initialMarginInUsdFromBalance = CalUtils.tokenToUsd(\n increaseMarginFromBalance,\n tokenDecimals,\n params.marginTokenPrice\n );\n position.positionFee.closeFeeInUsd = CalUtils.mulRate(increaseQty, symbolConfig.closeFeeRate);\n position.qty = increaseQty;\n position.leverage = params.leverage;\n position.realizedPnl = -(CalUtils.tokenToUsd(fee, tokenDecimals, params.marginTokenPrice).toInt256());\n position.positionFee.openBorrowingFeePerToken = MarketQueryProcess.getCumulativeBorrowingFeePerToken(\n symbolProps.stakeToken,\n params.isLong,\n params.marginToken\n );\n position.positionFee.openFundingFeePerQty = MarketQueryProcess.getFundingFeePerQty(\n symbolProps.code,\n params.isLong\n );\n } else {\n FeeProcess.updateBorrowingFee(position, symbolProps.stakeToken);\n FeeProcess.updateFundingFee(position);\n position.entryPrice = CalUtils.computeAvgEntryPrice(\n position.qty,\n position.entryPrice,\n increaseQty,\n params.indexTokenPrice,\n symbolConfig.tickSize,\n params.isLong\n );\n position.initialMargin += increaseMargin;\n position.initialMarginInUsd += CalUtils.tokenToUsd(increaseMargin, tokenDecimals, params.marginTokenPrice);\n position.initialMarginInUsdFromBalance += CalUtils.tokenToUsd(\n increaseMarginFromBalance,\n tokenDecimals,\n params.marginTokenPrice\n );\n position.positionFee.closeFeeInUsd += CalUtils.mulRate(increaseQty, symbolConfig.closeFeeRate);\n position.qty += increaseQty;\n position.realizedPnl += -(CalUtils.tokenToUsd(fee, tokenDecimals, params.marginTokenPrice).toInt256());\n }\n\n position.lastUpdateTime = ChainUtils.currentTimestamp();\n uint256 increaseHoldAmount = CalUtils.mulRate(increaseMargin, (params.leverage - 1 * CalUtils.RATE_PRECISION));\n position.holdPoolAmount += increaseHoldAmount;\n\n // update & verify OI\n MarketProcess.updateMarketOI(\n MarketProcess.UpdateOIParams(\n true,\n symbolProps.code,\n params.marginToken,\n increaseQty,\n params.indexTokenPrice,\n params.isLong\n )\n );\n\n LpPoolProcess.holdPoolAmount(symbolProps.stakeToken, position.marginToken, increaseHoldAmount, params.isLong);\n\n position.emitPositionUpdateEvent(\n params.requestId,\n Position.PositionUpdateFrom.ORDER_INCREASE,\n params.indexTokenPrice\n );\n }\n}\n" + }, + "contracts/process/LiquidationProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"./PositionQueryProcess.sol\";\nimport \"./DecreasePositionProcess.sol\";\nimport \"./CancelOrderProcess.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/Order.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/LiabilityClean.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary LiquidationProcess {\n using Math for uint256;\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SignedSafeMath for int256;\n using Position for Position.Props;\n using DecreasePositionProcess for Position.Props;\n using PositionQueryProcess for Position.Props;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n using Order for Order.Props;\n using Config for Config.Props;\n\n event LiquidationAccountIgnored(address account);\n event LiquidationPositionIgnored(bytes32 positionKey);\n\n bytes32 constant CLEAN_ID_KEY = keccak256(\"CLEAN_ID_KEY\");\n bytes32 constant LIQUIDATION_ID_KEY = keccak256(\"LIQUIDATION_ID_KEY\");\n\n function liquidationCrossPositions(address account) external {\n Account.Props storage accountProps = Account.load(account);\n Position.Props[] memory crossPositions = PositionQueryProcess.getAllPosition(accountProps, true);\n if (crossPositions.length == 0) {\n revert Errors.OnlyCrossSupported();\n }\n\n CancelOrderProcess.cancelAllCrossOrders(account, CancelOrderProcess.CANCEL_ORDER_LIQUIDATION);\n for (uint256 i; i < crossPositions.length; i++) {\n Symbol.Props memory symbolProps = Symbol.load(crossPositions[i].symbol);\n MarketProcess.updateMarketFundingFeeRate(crossPositions[i].symbol);\n MarketProcess.updatePoolBorrowingFeeRate(\n symbolProps.stakeToken,\n crossPositions[i].isLong,\n crossPositions[i].marginToken\n );\n }\n console.log(\"liquidation account\", account);\n if (!accountProps.isCrossLiquidation()) {\n emit LiquidationAccountIgnored(account);\n return;\n }\n\n (uint256 crossNetValue, uint256 totalQty) = accountProps.getCrossNetValueAndTotalQty();\n console.log(\"crossNetValue\", crossNetValue, \"totalQty\", totalQty);\n // todo: crossNetValue < 0,怎么算\n uint256 bankruptcyMR = CalUtils.divToPrecision(crossNetValue, totalQty, CalUtils.SMALL_RATE_PRECISION);\n console.log(\"bankruptcyMR\", bankruptcyMR);\n\n uint256 requestId = UuidCreator.nextId(LIQUIDATION_ID_KEY);\n for (uint256 i; i < crossPositions.length; i++) {\n Position.Props memory position = crossPositions[i];\n Symbol.Props memory symbolProps = Symbol.load(position.symbol);\n uint256 indexPrice = OracleProcess.getLatestUsdUintPrice(position.indexToken, position.isLong);\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(symbolProps.code);\n console.log(\"i=\", i, \"indexPrice\", indexPrice);\n uint256 bankruptcyPrice = CalUtils.formatToTickSize(\n position.isLong\n ? CalUtils.mulSmallRate(indexPrice, (CalUtils.SMALL_RATE_PRECISION - bankruptcyMR))\n : CalUtils.mulSmallRate(indexPrice, (CalUtils.SMALL_RATE_PRECISION + bankruptcyMR)),\n symbolConfig.tickSize,\n position.isLong\n );\n\n console.log(\"bankruptcyPrice\", bankruptcyPrice, \"indexPrice\", indexPrice);\n\n uint256 liquidationPrice = CalUtils.formatToTickSize(\n position.isLong\n ? CalUtils.divRate(\n bankruptcyPrice,\n CalUtils.RATE_PRECISION - PositionQueryProcess.getPositionMMRate(position)\n )\n : CalUtils.divRate(\n bankruptcyPrice,\n CalUtils.RATE_PRECISION + PositionQueryProcess.getPositionMMRate(position)\n ),\n symbolConfig.tickSize,\n position.isLong\n );\n\n Position.load(position.key).decreasePosition(\n DecreasePositionProcess.DecreasePositionParams(\n requestId,\n position.symbol,\n true,\n true,\n position.marginToken,\n position.qty,\n liquidationPrice\n )\n );\n }\n\n _updateClean(accountProps);\n }\n\n function liquidationIsolatePosition(bytes32 positionKey) external {\n Position.Props storage position = Position.load(positionKey);\n position.checkExists();\n if (position.isCrossMargin) {\n revert Errors.OnlyIsolateSupported();\n }\n MarketProcess.updateMarketFundingFeeRate(position.symbol);\n MarketProcess.updatePoolBorrowingFeeRate(\n Symbol.load(position.symbol).stakeToken,\n position.isLong,\n position.marginToken\n );\n\n uint256 indexPrice = OracleProcess.getLatestUsdUintPrice(position.indexToken, position.isLong);\n uint256 liquidationPrice = position.getLiquidationPrice();\n if ((position.isLong && indexPrice > liquidationPrice) || (!position.isLong && indexPrice < liquidationPrice)) {\n emit LiquidationPositionIgnored(positionKey);\n return;\n }\n\n CancelOrderProcess.cancelSymbolOrders(\n position.account,\n position.symbol,\n position.marginToken,\n CancelOrderProcess.CANCEL_ORDER_LIQUIDATION\n );\n\n position.decreasePosition(\n DecreasePositionProcess.DecreasePositionParams(\n UuidCreator.nextId(LIQUIDATION_ID_KEY),\n position.symbol,\n true,\n false,\n position.marginToken,\n position.qty,\n liquidationPrice\n )\n );\n }\n\n function _updateClean(Account.Props storage accountProps) internal {\n uint256 cleanId = UuidCreator.nextId(CLEAN_ID_KEY);\n LiabilityClean.LiabilityCleanInfo storage cleanInfo = LiabilityClean.newClean(cleanId);\n cleanInfo.account = accountProps.owner;\n cleanInfo.liquidationTime = ChainUtils.currentTimestamp();\n address[] memory tokens = accountProps.getTokens();\n for (uint256 i; i < tokens.length; i++) {\n Account.TokenBalance memory temp = accountProps.getTokenBalance(tokens[i]);\n if (temp.amount > 0) {\n cleanInfo.collaterals.push(tokens[i]);\n cleanInfo.collateralsAmount.push(temp.amount);\n }\n if (temp.liability > 0) {\n cleanInfo.liabilityTokens.push(tokens[i]);\n cleanInfo.liabilities.push(temp.liability);\n accountProps.clearLiability(tokens[i]);\n }\n }\n for (uint256 i; i < tokens.length; i++) {\n Account.TokenBalance memory temp = accountProps.getTokenBalance(tokens[i]);\n if (temp.amount > 0) {\n accountProps.subToken(tokens[i], temp.amount);\n }\n }\n }\n}\n" + }, + "contracts/process/LpPoolProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../utils/Errors.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./MarketProcess.sol\";\nimport \"./LpPoolQueryProcess.sol\";\n\nlibrary LpPoolProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedSafeMath for int256;\n using LpPool for LpPool.Props;\n using LpPoolQueryProcess for LpPool.Props;\n using UsdPool for UsdPool.Props;\n\n function holdPoolAmount(address stakeToken, address token, uint256 amount, bool isLong) external {\n if (isLong) {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n if (pool.getPoolAvailableLiquidity() < amount) {\n revert Errors.PoolAmountNotEnough(stakeToken, token);\n }\n pool.holdBaseToken(amount);\n } else {\n UsdPool.Props storage pool = UsdPool.load();\n if (!UsdPool.isHoldAmountAllowed(pool.stableTokenBalances[token], UsdPool.getPoolLiquidityLimit(), amount)) {\n revert Errors.PoolAmountNotEnough(stakeToken, token);\n }\n pool.holdStableToken(token, amount);\n }\n }\n\n function updatePnlAndUnHoldPoolAmount(\n address stakeToken,\n address token,\n uint256 amount,\n int256 tokenPnl,\n uint256 addLiability\n ) external {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n if (pool.baseToken == token) {\n pool.unHoldBaseToken(amount);\n if (tokenPnl > 0) {\n uint256 utokenPnl = tokenPnl.toUint256();\n pool.addBaseToken(utokenPnl > addLiability ? utokenPnl - addLiability : 0);\n pool.addUnsettleBaseToken(utokenPnl > addLiability ? addLiability.toInt256() : tokenPnl);\n } else if (tokenPnl < 0) {\n pool.subBaseToken((-tokenPnl).toUint256());\n }\n } else {\n UsdPool.Props storage usdPool = UsdPool.load();\n usdPool.unHoldStableToken(token, amount);\n if (tokenPnl >= 0) {\n uint256 utokenPnl = tokenPnl.toUint256();\n pool.addStableToken(token, utokenPnl > addLiability ? utokenPnl - addLiability : 0);\n pool.addUnsettleStableToken(token, utokenPnl > addLiability ? addLiability.toInt256() : tokenPnl);\n } else {\n uint256 utokenPnl = (-tokenPnl).toUint256();\n pool.addLossStableToken(token, utokenPnl);\n usdPool.subStableToken(token, utokenPnl);\n usdPool.addUnsettleStableToken(token, utokenPnl);\n }\n }\n }\n\n function validate(LpPool.Props storage pool) public view {\n if (LpPoolQueryProcess.getPoolIntValue(pool) < 0) {\n revert Errors.PoolValueLessThanZero();\n }\n }\n\n function subPoolAmount(LpPool.Props storage pool, address token, uint256 amount) external {\n if (!pool.isSubAmountAllowed(token, amount)) {\n revert Errors.PoolAmountNotEnough(pool.stakeToken, token);\n }\n if (pool.baseToken == token) {\n pool.subBaseToken(amount);\n } else {\n pool.subStableToken(token, amount);\n }\n validate(pool);\n }\n}\n" + }, + "contracts/process/LpPoolQueryProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../interfaces/IPool.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Market.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"./OracleProcess.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary LpPoolQueryProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedSafeMath for int256;\n using LpPool for LpPool.Props;\n using UsdPool for UsdPool.Props;\n using Config for Config.Props;\n\n function getUsdPool() external view returns (IPool.UsdPoolInfo memory) {\n UsdPool.Props storage pool = UsdPool.load();\n if (pool.getStableTokens().length == 0) {\n IPool.UsdPoolInfo memory poolInfo;\n return poolInfo;\n }\n address stakeUsdToken = CommonData.getStakeUsdToken();\n uint256 totalSupply = IERC20(stakeUsdToken).totalSupply();\n address[] memory stableTokens = pool.getStableTokens();\n uint256[] memory tokensAvailableLiquidity = new uint256[](stableTokens.length);\n for (uint256 i; i < stableTokens.length; i++) {\n tokensAvailableLiquidity[i] = getUsdPoolAvailableLiquidity(pool, stableTokens[i]);\n }\n return\n IPool.UsdPoolInfo(\n stableTokens,\n pool.getStableTokenBalanceArray(),\n pool.getMaxWithdrawArray(),\n 0,\n totalSupply,\n tokensAvailableLiquidity,\n pool.getAllBorrowingFees(),\n pool.apr\n );\n }\n\n function getUsdPoolWithOracle(\n OracleProcess.OracleParam[] calldata oracles\n ) external view returns (IPool.UsdPoolInfo memory) {\n UsdPool.Props storage pool = UsdPool.load();\n if (pool.getStableTokens().length == 0) {\n IPool.UsdPoolInfo memory poolInfo;\n return poolInfo;\n }\n address stakeUsdToken = CommonData.getStakeUsdToken();\n uint256 totalSupply = IERC20(stakeUsdToken).totalSupply();\n address[] memory stableTokens = pool.getStableTokens();\n uint256[] memory tokensAvailableLiquidity = new uint256[](stableTokens.length);\n for (uint256 i; i < stableTokens.length; i++) {\n tokensAvailableLiquidity[i] = getUsdPoolAvailableLiquidity(pool, stableTokens[i]);\n }\n return\n IPool.UsdPoolInfo(\n stableTokens,\n pool.getStableTokenBalanceArray(),\n pool.getMaxWithdrawArray(),\n oracles.length > 0 ? getUsdPoolValue(pool, oracles) : 0,\n totalSupply,\n tokensAvailableLiquidity,\n pool.getAllBorrowingFees(),\n pool.apr\n );\n }\n\n function getAllPools(OracleProcess.OracleParam[] calldata oracles) external view returns (IPool.PoolInfo[] memory) {\n address[] memory stakeTokens = CommonData.getAllStakeTokens();\n IPool.PoolInfo[] memory poolInfos = new IPool.PoolInfo[](stakeTokens.length);\n for (uint256 i; i < stakeTokens.length; i++) {\n poolInfos[i] = getPool(stakeTokens[i], oracles);\n }\n return poolInfos;\n }\n\n function getPoolValue(LpPool.Props storage pool) public view returns (uint256) {\n int256 poolValue = getPoolIntValue(pool);\n return poolValue <= 0 ? 0 : poolValue.toUint256();\n }\n\n function getPoolValue(\n LpPool.Props storage pool,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (uint256) {\n int256 poolValue = getPoolIntValue(pool, oracles);\n return poolValue <= 0 ? 0 : poolValue.toUint256();\n }\n\n function getPoolIntValue(LpPool.Props storage pool) public view returns (int256) {\n OracleProcess.OracleParam[] memory oracles;\n return getPoolIntValue(pool, oracles);\n }\n\n function getPoolIntValue(\n LpPool.Props storage pool,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (int256) {\n int256 value = 0;\n if (pool.baseTokenBalance.amount > 0 || pool.baseTokenBalance.unsettledAmount > 0) {\n int256 unpnl = getMarketUnpnl(pool.symbol, oracles, true, pool.baseToken, true);\n int256 baseTokenPrice = OracleProcess.getIntOraclePrices(oracles, pool.baseToken, true);\n value = CalUtils.tokenToUsdInt(\n (pool.baseTokenBalance.amount.toInt256() + pool.baseTokenBalance.unsettledAmount + unpnl),\n TokenUtils.decimals(pool.baseToken),\n baseTokenPrice\n );\n }\n address[] memory stableTokens = pool.getStableTokens();\n if (stableTokens.length > 0) {\n for (uint256 i; i < stableTokens.length; i++) {\n LpPool.TokenBalance storage tokenBalance = pool.stableTokenBalances[stableTokens[i]];\n if (tokenBalance.amount > 0 || tokenBalance.unsettledAmount > 0) {\n int256 unpnl = getMarketUnpnl(pool.symbol, oracles, false, stableTokens[i], true);\n value = value.add(\n CalUtils.tokenToUsdInt(\n (tokenBalance.amount.toInt256() +\n tokenBalance.unsettledAmount -\n tokenBalance.lossAmount.toInt256() +\n unpnl),\n TokenUtils.decimals(stableTokens[i]),\n OracleProcess.getIntOraclePrices(oracles, stableTokens[i], true)\n )\n );\n }\n }\n }\n return value;\n }\n\n function getPoolAvailableLiquidity(LpPool.Props storage pool) external view returns (uint256) {\n OracleProcess.OracleParam[] memory oracles;\n return getPoolAvailableLiquidity(pool, oracles);\n }\n\n function getPoolAvailableLiquidity(\n LpPool.Props storage pool,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (uint256) {\n int256 baseTokenAmount = pool.baseTokenBalance.amount.toInt256() + pool.baseTokenBalance.unsettledAmount;\n if (baseTokenAmount < 0) {\n return 0;\n }\n\n address[] memory stableTokens = pool.getStableTokens();\n if (stableTokens.length > 0) {\n uint8 baseTokenDecimals = TokenUtils.decimals(pool.baseToken);\n int256 baseTokenPrice = OracleProcess.getIntOraclePrices(oracles, pool.baseToken, true);\n for (uint256 i; i < stableTokens.length; i++) {\n LpPool.TokenBalance storage tokenBalance = pool.stableTokenBalances[stableTokens[i]];\n if (\n tokenBalance.lossAmount > 0 &&\n tokenBalance.amount.toInt256() + tokenBalance.unsettledAmount < tokenBalance.lossAmount.toInt256()\n ) {\n int256 tokenUsd = CalUtils.tokenToUsdInt(\n tokenBalance.lossAmount.toInt256() -\n tokenBalance.amount.toInt256() -\n tokenBalance.unsettledAmount,\n TokenUtils.decimals(stableTokens[i]),\n OracleProcess.getIntOraclePrices(oracles, stableTokens[i], true)\n );\n int256 stableToBaseToken = CalUtils.usdToTokenInt(tokenUsd, baseTokenDecimals, baseTokenPrice);\n if (baseTokenAmount > stableToBaseToken) {\n baseTokenAmount -= stableToBaseToken;\n } else {\n baseTokenAmount = 0;\n }\n }\n }\n }\n int256 availableTokenAmount = CalUtils.mulRate(baseTokenAmount, pool.getPoolLiquidityLimit().toInt256());\n return\n availableTokenAmount > pool.baseTokenBalance.holdAmount.toInt256()\n ? (availableTokenAmount - pool.baseTokenBalance.holdAmount.toInt256()).toUint256()\n : 0;\n }\n\n function getUsdPoolAvailableLiquidity(UsdPool.Props storage pool, address token) public view returns (uint256) {\n UsdPool.TokenBalance memory tokenBalance = pool.getStableTokenBalance(token);\n uint256 totalAmount = tokenBalance.amount + tokenBalance.unsettledAmount;\n uint256 availableTokenAmount = CalUtils.mulRate(totalAmount, UsdPool.getPoolLiquidityLimit());\n return availableTokenAmount > tokenBalance.holdAmount ? availableTokenAmount - tokenBalance.holdAmount : 0;\n }\n\n function getUsdPoolValue(UsdPool.Props storage pool) public view returns (uint256) {\n OracleProcess.OracleParam[] memory oracles;\n return getUsdPoolValue(pool, oracles);\n }\n\n function getUsdPoolValue(\n UsdPool.Props storage pool,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (uint256) {\n int256 poolValue = getUsdPoolIntValue(pool, oracles);\n return poolValue <= 0 ? 0 : poolValue.toUint256();\n }\n\n function getUsdPoolIntValue(UsdPool.Props storage pool) public view returns (int256) {\n OracleProcess.OracleParam[] memory oracles;\n return getUsdPoolIntValue(pool, oracles);\n }\n\n function getUsdPoolIntValue(\n UsdPool.Props storage pool,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (int256) {\n int256 value = 0;\n address[] memory stableTokens = pool.getStableTokens();\n if (stableTokens.length > 0) {\n for (uint256 i; i < stableTokens.length; i++) {\n UsdPool.TokenBalance storage tokenBalance = pool.stableTokenBalances[stableTokens[i]];\n if (tokenBalance.amount > 0 || tokenBalance.unsettledAmount > 0) {\n value = value.add(\n CalUtils.tokenToUsdInt(\n (tokenBalance.amount.toInt256() + tokenBalance.unsettledAmount.toInt256()),\n TokenUtils.decimals(stableTokens[i]),\n OracleProcess.getIntOraclePrices(oracles, stableTokens[i], true)\n )\n );\n }\n }\n }\n return value;\n }\n\n function getMarketUnpnl(\n bytes32 symbol,\n OracleProcess.OracleParam[] memory oracles,\n bool isLong,\n address marginToken,\n bool pnlToken\n ) public view returns (int256) {\n Market.Props storage market = Market.load(symbol);\n Market.MarketPosition storage position = isLong ? market.longPosition : market.shortPositionMap[marginToken];\n if (position.openInterest == 0) {\n return 0;\n }\n int256 markPrice = OracleProcess.getIntOraclePrices(oracles, marginToken, true);\n if (position.entryPrice == markPrice.toUint256()) {\n return 0;\n }\n if (isLong) {\n int pnlInUsd = position.openInterest.toInt256().mul(markPrice.sub(position.entryPrice.toInt256())).div(\n position.entryPrice.toInt256()\n );\n return\n pnlToken\n ? -CalUtils.usdToTokenInt(\n pnlInUsd,\n TokenUtils.decimals(marginToken),\n position.entryPrice.toInt256()\n )\n : -pnlInUsd;\n } else {\n int pnlInUsd = position.openInterest.toInt256().mul(position.entryPrice.toInt256().sub(markPrice)).div(\n position.entryPrice.toInt256()\n );\n if (pnlToken) {\n int256 marginTokenPrice = OracleProcess.getIntOraclePrices(oracles, marginToken, false);\n return -CalUtils.usdToTokenInt(pnlInUsd, TokenUtils.decimals(marginToken), marginTokenPrice);\n } else {\n return -pnlInUsd;\n }\n }\n }\n\n function getPool(\n address stakeToken,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (IPool.PoolInfo memory) {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n address[] memory stableTokens = pool.getStableTokens();\n uint256 totalSupply = IERC20(stakeToken).totalSupply();\n return\n IPool.PoolInfo(\n stakeToken,\n pool.stakeTokenName,\n pool.baseToken,\n pool.symbol,\n _convertPoolBalance(pool.baseTokenBalance),\n stableTokens,\n _convertPoolStableBalance(stableTokens, pool.stableTokenBalances),\n oracles.length > 0 ? getPoolValue(pool, oracles) : 0,\n oracles.length > 0 ? getPoolAvailableLiquidity(pool, oracles) : 0,\n 0,\n totalSupply,\n pool.borrowingFee,\n pool.apr\n );\n }\n\n function _convertPoolBalance(\n LpPool.TokenBalance storage balance\n ) internal view returns (IPool.MintTokenBalance memory) {\n (address[] memory collateralTokens, uint256[] memory amounts) = LpPool.getCollateralTokenAmounts(\n balance.collateralTokenAmounts\n );\n return\n IPool.MintTokenBalance(\n balance.amount,\n balance.liability,\n balance.holdAmount,\n balance.unsettledAmount,\n balance.lossAmount,\n collateralTokens,\n amounts\n );\n }\n\n function _convertPoolStableBalance(\n address[] memory stableTokens,\n mapping(address => LpPool.TokenBalance) storage stableTokenBalances\n ) internal view returns (IPool.MintTokenBalance[] memory) {\n IPool.MintTokenBalance[] memory stableTokenBalanceArray = new IPool.MintTokenBalance[](stableTokens.length);\n for (uint256 i; i < stableTokens.length; i++) {\n stableTokenBalanceArray[i] = _convertPoolBalance(stableTokenBalances[stableTokens[i]]);\n }\n return stableTokenBalanceArray;\n }\n\n function _convertPoolCollateralConfig(\n address[] memory collaterals,\n mapping(address => Config.StakeCollateralConfig) storage collateralConfigs\n ) internal view returns (Config.StakeCollateralConfig[] memory) {\n Config.StakeCollateralConfig[] memory collateralConfigsArray = new Config.StakeCollateralConfig[](\n collaterals.length\n );\n for (uint256 i; i < collaterals.length; i++) {\n collateralConfigsArray[i] = collateralConfigs[collaterals[i]];\n }\n return collateralConfigsArray;\n }\n}\n" + }, + "contracts/process/MarketFactoryProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"../storage/Symbol.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/Market.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../vault/StakeToken.sol\";\n\nlibrary MarketFactoryProcess {\n using Market for Market.Props;\n\n event MarketCreated(bytes32 code, string stakeTokenName, address indexToken, address baseToken, address stakeToken);\n\n event PoolCreated(string name, address stakeToken);\n\n event MarketOIUpdateEvent(bytes32 symbol, bool isLong, uint256 openInterest);\n\n struct CreateMarketParams {\n bytes32 code;\n string stakeTokenName;\n address indexToken;\n address baseToken;\n }\n\n function createMarket(CreateMarketParams memory params) external returns (address stakeTokenAddr) {\n Symbol.Props storage symbolProps = Symbol.create(params.code);\n if (symbolProps.indexToken != address(0)) {\n revert Errors.CreateSymbolExists(params.code);\n }\n symbolProps.indexToken = params.indexToken;\n symbolProps.baseToken = params.baseToken;\n symbolProps.status = Symbol.Status.OPEN;\n ERC20 baseTokenERC20 = ERC20(params.baseToken);\n bytes32 stakeTokenSalt = keccak256(abi.encode(\"STAKE_TOKEN\", params.stakeTokenName));\n StakeToken stakeToken = new StakeToken{ salt: stakeTokenSalt }(\n params.stakeTokenName,\n baseTokenERC20.decimals()\n );\n stakeTokenAddr = address(stakeToken);\n symbolProps.stakeToken = stakeTokenAddr;\n\n LpPool.Props storage pool = LpPool.load(stakeTokenAddr);\n if (pool.stakeToken != address(0)) {\n revert Errors.CreateStakePoolExists(stakeTokenAddr);\n }\n pool.stakeToken = stakeTokenAddr;\n pool.stakeTokenName = params.stakeTokenName;\n pool.baseToken = params.baseToken;\n pool.symbol = params.code;\n CommonData.addSymbol(params.code);\n CommonData.addStakeTokens(stakeTokenAddr);\n\n Market.Props storage marketProps = Market.load(params.code);\n marketProps.symbol = params.code;\n marketProps.stakeToken = stakeTokenAddr;\n\n emit MarketCreated(params.code, params.stakeTokenName, params.indexToken, params.baseToken, stakeTokenAddr);\n }\n\n function createStakeUsdPool(string memory stakeTokenName) external returns (address stakeTokenAddr) {\n if (CommonData.getStakeUsdToken() != address(0)) {\n revert Errors.CreateStakePoolExists(CommonData.getStakeUsdToken());\n }\n bytes32 stakeTokenSalt = keccak256(abi.encode(\"STAKE_USD_TOKEN\", stakeTokenName));\n StakeToken stakeToken = new StakeToken{ salt: stakeTokenSalt }(stakeTokenName, 6);\n stakeTokenAddr = address(stakeToken);\n\n LpPool.Props storage pool = LpPool.load(stakeTokenAddr);\n pool.stakeToken = stakeTokenAddr;\n\n CommonData.setStakeUsdToken(stakeTokenAddr);\n emit PoolCreated(stakeTokenName, stakeTokenAddr);\n }\n}\n" + }, + "contracts/process/MarketProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"./MarketQueryProcess.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/Market.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"../utils/ChainUtils.sol\";\n\nlibrary MarketProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using Math for uint256;\n using SignedSafeMath for int256;\n using SafeCast for int256;\n using Market for Market.Props;\n using MarketQueryProcess for Market.Props;\n using UsdPool for UsdPool.Props;\n using LpPool for LpPool.Props;\n using Config for Config.Props;\n\n event MarketOIUpdateEvent(bytes32 symbol, bool isLong, uint256 openInterest);\n\n struct UpdateOIParams {\n bool isAdd;\n bytes32 symbol;\n address token;\n uint256 qty;\n uint256 entryPrice;\n bool isLong;\n }\n\n struct UpdateFundingCache {\n uint256 totalLongOpenInterest;\n uint256 totalShortOpenInterest;\n uint256 fundingFeeDurationInSecond;\n uint256 fundingRatePerSecond;\n uint256 totalFundingFee;\n int256 longFundingFeePerQtyDelta;\n int256 shortFundingFeePerQtyDelta;\n }\n\n function updateMarketFundingFeeRate(bytes32 symbol) external {\n UpdateFundingCache memory cache;\n Market.Props storage market = Market.load(symbol);\n Symbol.Props storage symbolProps = Symbol.load(symbol);\n cache.totalLongOpenInterest = market.getLongOpenInterest();\n cache.totalShortOpenInterest = market.getAllShortOpenInterest();\n if (cache.totalLongOpenInterest == 0 || cache.totalShortOpenInterest == 0) {\n market.fundingFee.lastUpdateTime = ChainUtils.currentTimestamp();\n return;\n }\n cache.fundingFeeDurationInSecond = _getFundingFeeDurations(market);\n cache.fundingRatePerSecond = market.getFundingRatePerSecond();\n cache.totalFundingFee = Math\n .max(cache.totalLongOpenInterest, cache.totalShortOpenInterest)\n .mul(cache.fundingFeeDurationInSecond)\n .mul(cache.fundingRatePerSecond);\n cache.longFundingFeePerQtyDelta = CalUtils\n .usdToToken(\n cache.totalFundingFee.div(cache.totalLongOpenInterest),\n TokenUtils.decimals(symbolProps.baseToken),\n OracleProcess.getLatestUsdUintPrice(symbolProps.baseToken, true)\n )\n .toInt256();\n cache.shortFundingFeePerQtyDelta = cache.totalFundingFee.div(cache.totalShortOpenInterest).toInt256();\n if (cache.totalLongOpenInterest < cache.totalShortOpenInterest) {\n cache.shortFundingFeePerQtyDelta = -cache.shortFundingFeePerQtyDelta;\n } else {\n cache.longFundingFeePerQtyDelta = -cache.longFundingFeePerQtyDelta;\n }\n\n market.fundingFee.longFundingFeePerQty += cache.longFundingFeePerQtyDelta;\n market.fundingFee.shortFundingFeePerQty += cache.shortFundingFeePerQtyDelta;\n market.fundingFee.lastUpdateTime = ChainUtils.currentTimestamp();\n }\n\n function updatePoolBorrowingFeeRate(address stakeToken, bool isLong, address marginToken) external {\n if (isLong) {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n uint256 borrowingFeeDurationInSecond = _getFeeDurations(pool.borrowingFee.lastUpdateTime);\n pool.borrowingFee.cumulativeBorrowingFeePerToken += MarketQueryProcess\n .getLongBorrowingRatePerSecond(pool)\n .mul(borrowingFeeDurationInSecond);\n pool.borrowingFee.lastUpdateTime = ChainUtils.currentTimestamp();\n } else {\n UsdPool.Props storage usdPool = UsdPool.load();\n UsdPool.BorrowingFee storage borrowingFees = usdPool.getBorrowingFees(marginToken);\n uint256 borrowingFeeDurationInSecond = _getFeeDurations(borrowingFees.lastUpdateTime);\n borrowingFees.cumulativeBorrowingFeePerToken += MarketQueryProcess\n .getShortBorrowingRatePerSecond(usdPool, marginToken)\n .mul(borrowingFeeDurationInSecond);\n borrowingFees.lastUpdateTime = ChainUtils.currentTimestamp();\n }\n }\n\n function updateTotalBorrowingFee(\n address stakeToken,\n bool isLong,\n address marginToken,\n int256 borrowingFee,\n int256 realizedBorrowingFee\n ) external {\n if (isLong) {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n pool.borrowingFee.totalBorrowingFee = borrowingFee > 0\n ? (pool.borrowingFee.totalBorrowingFee + borrowingFee.toUint256())\n : (pool.borrowingFee.totalBorrowingFee - (-borrowingFee).toUint256());\n pool.borrowingFee.totalRealizedBorrowingFee = realizedBorrowingFee > 0\n ? (pool.borrowingFee.totalRealizedBorrowingFee + realizedBorrowingFee.toUint256())\n : (pool.borrowingFee.totalRealizedBorrowingFee - (-realizedBorrowingFee).toUint256());\n } else {\n UsdPool.Props storage usdPool = UsdPool.load();\n UsdPool.BorrowingFee storage borrowingFees = usdPool.getBorrowingFees(marginToken);\n borrowingFees.totalBorrowingFee = borrowingFee > 0\n ? (borrowingFees.totalBorrowingFee + borrowingFee.toUint256())\n : (borrowingFees.totalBorrowingFee - (-borrowingFee).toUint256());\n borrowingFees.totalRealizedBorrowingFee = realizedBorrowingFee > 0\n ? (borrowingFees.totalRealizedBorrowingFee + realizedBorrowingFee.toUint256())\n : (borrowingFees.totalRealizedBorrowingFee - (-realizedBorrowingFee).toUint256());\n }\n }\n\n function updateMarketFundingFee(\n bytes32 symbol,\n int256 realizedFundingFeeDelta,\n bool isLong,\n bool needUpdateUnsettle,\n address marginToken\n ) external {\n Market.Props storage market = Market.load(symbol);\n if (isLong) {\n market.fundingFee.totalLongFundingFee += realizedFundingFeeDelta;\n } else {\n market.fundingFee.totalShortFundingFee += realizedFundingFeeDelta;\n }\n if (needUpdateUnsettle) {\n Symbol.Props storage symbolProps = Symbol.load(symbol);\n LpPool.Props storage pool = LpPool.load(symbolProps.stakeToken);\n if (isLong) {\n pool.addUnsettleBaseToken(realizedFundingFeeDelta);\n } else {\n pool.addUnsettleStableToken(marginToken, realizedFundingFeeDelta);\n }\n }\n }\n\n function updateMarketOI(UpdateOIParams memory params) external {\n Market.Props storage market = Market.load(params.symbol);\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(params.symbol);\n if (params.isAdd && params.isLong) {\n _addOI(market.longPosition, params, symbolConfig.tickSize);\n } else if (params.isAdd && !params.isLong) {\n market.addShortToken(params.token);\n _addOI(market.shortPositionMap[params.token], params, symbolConfig.tickSize);\n } else if (!params.isAdd) {\n _subOI(params.isLong ? market.longPosition : market.shortPositionMap[params.token], params);\n }\n\n if (params.isAdd) {\n uint256 longOpenInterest = market.getLongOpenInterest();\n uint256 shortOpenInterest = market.getAllShortOpenInterest();\n if (params.isLong && longOpenInterest > symbolConfig.maxLongOpenInterestCap) {\n revert Errors.MaxOILimited(params.symbol, params.isLong);\n }\n if (!params.isLong && shortOpenInterest > symbolConfig.maxShortOpenInterestCap) {\n revert Errors.MaxOILimited(params.symbol, params.isLong);\n }\n uint256 minOpenInterest = longOpenInterest.min(shortOpenInterest);\n if (minOpenInterest < symbolConfig.longShortOiBottomLimit) {\n return;\n }\n if (\n longOpenInterest.max(shortOpenInterest) - minOpenInterest >\n CalUtils.mulRate(longOpenInterest + shortOpenInterest, symbolConfig.longShortRatioLimit)\n ) {\n revert Errors.OIRatioLimited();\n }\n }\n }\n\n function _getFundingFeeDurations(Market.Props storage market) internal view returns (uint256) {\n if (market.fundingFee.lastUpdateTime == 0) {\n return 0;\n }\n return ChainUtils.currentTimestamp() - market.fundingFee.lastUpdateTime;\n }\n\n function _getFeeDurations(uint256 lastUpdateTime) internal view returns (uint256) {\n if (lastUpdateTime == 0) {\n return 0;\n }\n return ChainUtils.currentTimestamp() - lastUpdateTime;\n }\n\n function _addOI(Market.MarketPosition storage position, UpdateOIParams memory params, uint256 tickSize) internal {\n if (position.openInterest == 0) {\n position.entryPrice = params.entryPrice;\n position.openInterest = params.qty;\n } else {\n position.entryPrice = CalUtils.computeAvgEntryPrice(\n position.openInterest,\n position.entryPrice,\n params.qty,\n params.entryPrice,\n tickSize,\n params.isLong\n );\n position.openInterest += params.qty;\n }\n emit MarketOIUpdateEvent(params.symbol, params.isLong, position.openInterest);\n }\n\n function _subOI(Market.MarketPosition storage position, UpdateOIParams memory params) internal {\n if (position.openInterest <= params.qty) {\n position.entryPrice = 0;\n position.openInterest = 0;\n } else {\n position.openInterest -= params.qty;\n }\n emit MarketOIUpdateEvent(params.symbol, params.isLong, position.openInterest);\n }\n}\n" + }, + "contracts/process/MarketQueryProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../interfaces/IMarket.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Market.sol\";\nimport \"../storage/Config.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./LpPoolQueryProcess.sol\";\n\nlibrary MarketQueryProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SignedSafeMath for int256;\n using SafeCast for int256;\n using LpPoolQueryProcess for LpPool.Props;\n using LpPoolQueryProcess for UsdPool.Props;\n using UsdPool for UsdPool.Props;\n using Market for Market.Props;\n using Config for Config.Props;\n\n function getMarketInfo(bytes32 symbol, OracleProcess.OracleParam[] calldata oracles) external view returns (IMarket.MarketInfo memory) {\n Symbol.Props memory symbolProps = Symbol.load(symbol);\n LpPool.Props storage pool = LpPool.load(symbolProps.stakeToken);\n uint256 availableLiquidity = pool.getPoolAvailableLiquidity(oracles);\n Market.Props storage market = Market.load(symbol);\n uint256 longPositionInterest = market.longPosition.openInterest;\n uint256 totalShortPositionInterest = market.getAllShortOpenInterest();\n return\n IMarket.MarketInfo(\n symbolProps,\n longPositionInterest,\n market.longPosition.entryPrice,\n totalShortPositionInterest,\n market.getAllShortPositions(),\n availableLiquidity,\n market.fundingFee\n );\n }\n\n function getCumulativeBorrowingFeePerToken(\n address stakeToken,\n bool isLong,\n address marginToken\n ) external view returns (uint256) {\n if (isLong) {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n return pool.borrowingFee.cumulativeBorrowingFeePerToken;\n } else {\n UsdPool.Props storage usdPool = UsdPool.load();\n return usdPool.getBorrowingFees(marginToken).cumulativeBorrowingFeePerToken;\n }\n }\n\n function getLongBorrowingRatePerSecond(LpPool.Props storage pool) external view returns (uint256) {\n if (pool.baseTokenBalance.amount == 0 && pool.baseTokenBalance.unsettledAmount == 0) {\n return 0;\n }\n int256 totalAmount = pool.baseTokenBalance.amount.toInt256() + pool.baseTokenBalance.unsettledAmount;\n if (totalAmount <= 0) {\n return 0;\n }\n uint256 holdRate = CalUtils.divToPrecision(\n pool.baseTokenBalance.holdAmount,\n totalAmount.toUint256(),\n CalUtils.SMALL_RATE_PRECISION\n );\n return CalUtils.mulSmallRate(holdRate, Config.load().lpPoolConfigs[pool.stakeToken].baseInterestRate);\n }\n\n function getShortBorrowingRatePerSecond(UsdPool.Props storage pool, address token) external view returns (uint256) {\n Config.UsdPoolConfig storage usdPoolConfig = Config.load().getUsdPoolConfig();\n if (pool.getStableTokenBalance(token).amount == 0 && pool.getStableTokenBalance(token).unsettledAmount == 0) {\n return 0;\n }\n uint256 holdRate = CalUtils.divToPrecision(\n pool.getStableTokenBalance(token).holdAmount,\n (pool.getStableTokenBalance(token).amount + pool.getStableTokenBalance(token).unsettledAmount),\n CalUtils.SMALL_RATE_PRECISION\n );\n return CalUtils.mulSmallRate(holdRate, usdPoolConfig.baseInterestRates[token]);\n }\n\n function getFundingFeePerQty(bytes32 symbol, bool isLong) external view returns (int256) {\n Market.Props storage market = Market.load(symbol);\n return isLong ? market.fundingFee.longFundingFeePerQty : market.fundingFee.shortFundingFeePerQty;\n }\n\n function getFundingRatePerSecond(Market.Props storage market) external view returns (uint256) {\n uint256 longPositionInterest = market.longPosition.openInterest;\n uint256 totalShortPositionInterest = market.getAllShortOpenInterest();\n uint256 diffOpenInterest = CalUtils.diff(longPositionInterest, totalShortPositionInterest);\n uint256 totalOpenInterest = longPositionInterest + totalShortPositionInterest;\n if (diffOpenInterest == 0 || totalOpenInterest == 0) {\n return 0;\n }\n return Math.mulDiv(diffOpenInterest, Config.load().tradeConfig.fundingFeeBaseRate, totalOpenInterest);\n }\n}\n" + }, + "contracts/process/MintProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"hardhat/console.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"../interfaces/IStake.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../vault/Vault.sol\";\nimport \"../vault/LpVault.sol\";\nimport \"../vault/StakeToken.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Mint.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"./GasProcess.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./LpPoolQueryProcess.sol\";\nimport \"./FeeProcess.sol\";\nimport \"./FeeRewardsProcess.sol\";\nimport \"./AccountProcess.sol\";\nimport \"./AssetsProcess.sol\";\nimport \"./FeeQueryProcess.sol\";\n\nlibrary MintProcess {\n using LpPool for LpPool.Props;\n using LpPoolQueryProcess for LpPool.Props;\n using UsdPool for UsdPool.Props;\n using LpPoolQueryProcess for UsdPool.Props;\n using StakingAccount for StakingAccount.Props;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n using Config for Config.Props;\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n\n bytes32 constant MINT_ID_KEY = keccak256(\"MINT_ID_KEY\");\n\n struct ExecuteMintCache {\n address mintToken;\n uint256 mintFee;\n uint8 mintTokenDecimals;\n uint256 mintTokenAmount;\n uint256 mintStakeAmount;\n }\n\n event CancelMintEvent(uint256 indexed requestId, Mint.Request data, bytes32 reasonCode);\n event MintSuccessEvent(uint256 indexed requestId, uint256 mintStakeAmount, Mint.Request data);\n event CreateMintEvent(uint256 indexed requestId, Mint.Request data);\n\n function createMintStakeTokenRequest(\n IStake.MintStakeTokenParams memory params,\n address account,\n address token,\n uint256 walletRequestTokenAmount,\n bool isExecutionFeeFromLpVault\n ) external {\n uint256 requestId = UuidCreator.nextId(MINT_ID_KEY);\n\n Mint.Request storage mintRequest = Mint.create(requestId);\n mintRequest.account = account;\n mintRequest.receiver = params.receiver;\n mintRequest.stakeToken = params.stakeToken;\n mintRequest.requestToken = token;\n mintRequest.minStakeAmount = params.minStakeAmount;\n mintRequest.requestTokenAmount = params.requestTokenAmount;\n mintRequest.walletRequestTokenAmount = walletRequestTokenAmount;\n mintRequest.executionFee = params.executionFee;\n mintRequest.isCollateral = params.isCollateral;\n mintRequest.isExecutionFeeFromLpVault = isExecutionFeeFromLpVault;\n\n emit CreateMintEvent(requestId, mintRequest);\n }\n\n function executeMintStakeToken(\n uint256 requestId,\n Mint.Request memory mintRequest\n ) external returns (uint256 stakeAmount) {\n if (mintRequest.account == address(0)) {\n revert Errors.MintRequestNotExists();\n }\n if (CommonData.getStakeUsdToken() == mintRequest.stakeToken) {\n stakeAmount = _mintStakeUsd(mintRequest);\n } else if (CommonData.isStakeTokenSupport(mintRequest.stakeToken)) {\n stakeAmount = _mintStakeToken(mintRequest);\n } else {\n revert Errors.StakeTokenInvalid(mintRequest.stakeToken);\n }\n if (!mintRequest.isCollateral && mintRequest.walletRequestTokenAmount > 0) {\n IVault(address(this)).getLpVault().transferOut(\n mintRequest.requestToken,\n mintRequest.stakeToken,\n mintRequest.walletRequestTokenAmount\n );\n }\n\n FeeRewardsProcess.updateAccountFeeRewards(mintRequest.account, mintRequest.stakeToken);\n \n Mint.remove(requestId);\n\n emit MintSuccessEvent(requestId, stakeAmount, mintRequest);\n }\n\n function cancelMintStakeToken(uint256 requestId, Mint.Request memory mintRequest, bytes32 reasonCode) external {\n if (mintRequest.walletRequestTokenAmount > 0) {\n VaultProcess.transferOut(\n mintRequest.isCollateral\n ? IVault(address(this)).getPortfolioVaultAddress()\n : IVault(address(this)).getLpVaultAddress(),\n mintRequest.requestToken,\n mintRequest.account,\n mintRequest.walletRequestTokenAmount\n );\n }\n Mint.remove(requestId);\n emit CancelMintEvent(requestId, mintRequest, reasonCode);\n }\n\n function validateAndDepositMintExecutionFee(\n address account,\n IStake.MintStakeTokenParams calldata params\n ) external returns (uint256, bool) {\n Config.Props storage config = Config.load();\n GasProcess.validateExecutionFeeLimit(params.executionFee, config.chainConfig.mintGasFeeLimit);\n if (params.isNativeToken && params.walletRequestTokenAmount >= params.executionFee) {\n return (params.walletRequestTokenAmount - params.executionFee, true);\n }\n require(msg.value == params.executionFee, \"mint with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n account,\n config.chainConfig.wrapperToken,\n params.executionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n return (params.walletRequestTokenAmount, false);\n }\n\n function _mintStakeToken(Mint.Request memory mintRequest) internal returns (uint256 stakeAmount) {\n if (mintRequest.requestTokenAmount > mintRequest.walletRequestTokenAmount) {\n _transferFromAccount(\n mintRequest.account,\n mintRequest.requestToken,\n mintRequest.requestTokenAmount - mintRequest.walletRequestTokenAmount\n );\n }\n\n StakingAccount.Props storage accountProps = StakingAccount.load(mintRequest.account);\n LpPool.Props storage pool = LpPool.load(mintRequest.stakeToken);\n Config.Props storage config = Config.load();\n Config.LpPoolConfig storage poolConfig = config.getPoolConfig(mintRequest.stakeToken);\n ExecuteMintCache memory cache;\n if (mintRequest.isCollateral) {\n if (!pool.isStakeCollateralSupport(mintRequest.requestToken)) {\n revert Errors.MintTokenInvalid(mintRequest.stakeToken, mintRequest.requestToken);\n }\n cache.mintToken = pool.baseToken;\n uint256 collateralPrice = OracleProcess.getLatestUsdUintPrice(\n mintRequest.requestToken,\n cache.mintToken,\n true\n );\n Config.StakeCollateralConfig memory collateralConfig = pool.getStakeCollateralConfig(\n mintRequest.requestToken\n );\n if (\n (collateralConfig.discount + config.getStakeConfig().collateralProtectFactor).mul(10 ** 3) >\n collateralPrice\n ) {\n revert Errors.MintCollateralFailedWithPriceCloseToDiscount();\n }\n\n cache.mintFee = FeeQueryProcess.calcMintOrRedeemFee(\n mintRequest.requestTokenAmount,\n poolConfig.mintFeeRate\n );\n FeeProcess.chargeMintOrRedeemFee(\n cache.mintFee,\n mintRequest.stakeToken, \n mintRequest.requestToken, \n mintRequest.receiver, \n FeeProcess.FEE_MINT,\n true\n );\n\n uint256 baseMintTokenAmount = mintRequest.requestTokenAmount - cache.mintFee;\n if (\n pool.getCollateralTokenAmount(mintRequest.requestToken) + baseMintTokenAmount >\n collateralConfig.collateralTotalCap\n ) {\n revert Errors.MintCollateralOverflow();\n }\n cache.mintTokenAmount = CalUtils.mulRate(baseMintTokenAmount, collateralConfig.discount);\n cache.mintTokenDecimals = TokenUtils.decimals(cache.mintToken);\n uint256 minMintStakeAmount = config.getStakeConfig().minPrecisionMultiple.mul(\n 10 ** (cache.mintTokenDecimals - config.getTradeTokenConfig(cache.mintToken).precision)\n );\n if (cache.mintTokenAmount < minMintStakeAmount) {\n revert Errors.MintStakeTokenTooSmall(minMintStakeAmount, cache.mintTokenAmount);\n }\n cache.mintStakeAmount = _executeMintStakeToken(mintRequest, pool, cache.mintTokenAmount);\n\n accountProps.addStakeAmount(mintRequest.stakeToken, cache.mintStakeAmount);\n accountProps.addStakeLiability(mintRequest.stakeToken, mintRequest.requestToken, cache.mintTokenAmount);\n accountProps.addCollateralToken(mintRequest.stakeToken, mintRequest.requestToken, baseMintTokenAmount);\n pool.addCollateralBaseToken(cache.mintTokenAmount, mintRequest.requestToken, baseMintTokenAmount);\n stakeAmount = cache.mintStakeAmount;\n } else {\n cache.mintToken = mintRequest.requestToken;\n if (pool.baseToken != cache.mintToken) {\n revert Errors.MintTokenInvalid(mintRequest.stakeToken, mintRequest.requestToken);\n }\n cache.mintTokenDecimals = TokenUtils.decimals(cache.mintToken);\n uint256 minMintStakeAmount = config.getStakeConfig().minPrecisionMultiple.mul(\n 10 ** (cache.mintTokenDecimals - config.getTradeTokenConfig(cache.mintToken).precision)\n );\n if (mintRequest.requestTokenAmount < minMintStakeAmount) {\n revert Errors.MintStakeTokenTooSmall(minMintStakeAmount, mintRequest.requestTokenAmount);\n }\n\n cache.mintFee = FeeQueryProcess.calcMintOrRedeemFee(\n mintRequest.requestTokenAmount,\n poolConfig.mintFeeRate\n );\n FeeProcess.chargeMintOrRedeemFee(\n cache.mintFee, \n mintRequest.stakeToken, \n mintRequest.requestToken, \n mintRequest.receiver, \n FeeProcess.FEE_MINT,\n false\n );\n\n cache.mintTokenAmount = mintRequest.requestTokenAmount - cache.mintFee;\n cache.mintStakeAmount = _executeMintStakeToken(mintRequest, pool, cache.mintTokenAmount);\n accountProps.addStakeAmount(mintRequest.stakeToken, cache.mintStakeAmount);\n pool.addBaseToken(cache.mintTokenAmount);\n stakeAmount = cache.mintStakeAmount;\n }\n }\n\n function _mintStakeUsd(Mint.Request memory mintRequest) internal returns (uint256 mintStakeAmount) {\n if (!UsdPool.isSupportStableToken(mintRequest.requestToken)) {\n revert Errors.MintTokenInvalid(mintRequest.stakeToken, mintRequest.requestToken);\n }\n Config.Props storage config = Config.load();\n uint8 mintTokenDecimals = TokenUtils.decimals(mintRequest.requestToken);\n uint256 minMintStakeAmount = config.getStakeConfig().minPrecisionMultiple.mul(\n 10 ** (mintTokenDecimals - config.getTradeTokenConfig(mintRequest.requestToken).precision)\n );\n if (mintRequest.requestTokenAmount < minMintStakeAmount) {\n revert Errors.MintStakeTokenTooSmall(minMintStakeAmount, mintRequest.requestTokenAmount);\n }\n if (mintRequest.walletRequestTokenAmount < mintRequest.requestTokenAmount) {\n _transferFromAccount(\n mintRequest.account,\n mintRequest.requestToken,\n mintRequest.requestTokenAmount - mintRequest.walletRequestTokenAmount\n );\n }\n\n uint256 mintFees = FeeQueryProcess.calcMintOrRedeemFee(\n mintRequest.requestTokenAmount,\n config.getUsdPoolConfig().mintFeeRate\n );\n FeeProcess.chargeMintOrRedeemFee(\n mintFees, \n mintRequest.stakeToken, \n mintRequest.requestToken, \n mintRequest.receiver, \n FeeProcess.FEE_MINT,\n false\n );\n\n uint256 baseMintAmount = mintRequest.requestTokenAmount - mintFees;\n\n UsdPool.Props storage pool = UsdPool.load();\n mintStakeAmount = _executeMintStakeUsd(mintRequest, pool, baseMintAmount);\n\n StakingAccount.Props storage accountProps = StakingAccount.load(mintRequest.account);\n accountProps.addStakeUsdAmount(mintStakeAmount);\n pool.addStableToken(mintRequest.requestToken, baseMintAmount);\n }\n\n function _executeMintStakeToken(\n Mint.Request memory params,\n LpPool.Props storage pool,\n uint256 baseMintAmount\n ) internal returns (uint256) {\n uint256 mintStakeTokenAmount = computeStakeAmountFromMintToken(pool, baseMintAmount);\n if (params.minStakeAmount > 0 && mintStakeTokenAmount < params.minStakeAmount) {\n revert Errors.MintStakeTokenTooSmall(params.minStakeAmount, mintStakeTokenAmount);\n }\n StakeToken(params.stakeToken).mint(params.receiver, mintStakeTokenAmount);\n return mintStakeTokenAmount;\n }\n\n function _executeMintStakeUsd(\n Mint.Request memory params,\n UsdPool.Props storage pool,\n uint256 baseMintAmount\n ) internal returns (uint256) {\n address stableToken = params.requestToken;\n uint256 totalSupply = TokenUtils.totalSupply(params.stakeToken);\n uint8 tokenDecimals = TokenUtils.decimals(stableToken);\n uint8 stakeTokenDecimals = TokenUtils.decimals(params.stakeToken);\n uint256 poolValue = pool.getUsdPoolValue();\n uint256 mintStakeTokenAmount;\n if (totalSupply == 0 && poolValue == 0) {\n mintStakeTokenAmount = CalUtils.decimalsToDecimals(baseMintAmount, tokenDecimals, stakeTokenDecimals);\n } else if (totalSupply == 0 && poolValue > 0) {\n uint256 totalBaseMintAmount = baseMintAmount +\n CalUtils.usdToToken(poolValue, tokenDecimals, OracleProcess.getLatestUsdUintPrice(stableToken, true));\n mintStakeTokenAmount = CalUtils.decimalsToDecimals(totalBaseMintAmount, tokenDecimals, stakeTokenDecimals);\n } else if (poolValue == 0) {\n revert Errors.PoolValueIsZero();\n } else {\n uint256 baseMintAmountInUsd = CalUtils.tokenToUsd(\n baseMintAmount,\n tokenDecimals,\n OracleProcess.getLatestUsdUintPrice(stableToken, true)\n );\n mintStakeTokenAmount = totalSupply.mul(baseMintAmountInUsd).div(poolValue);\n }\n if (params.minStakeAmount > 0 && mintStakeTokenAmount < params.minStakeAmount) {\n revert Errors.MintStakeTokenTooSmall(params.minStakeAmount, mintStakeTokenAmount);\n }\n\n StakeToken(params.stakeToken).mint(params.receiver, mintStakeTokenAmount);\n\n return mintStakeTokenAmount; \n }\n\n function _transferFromAccount(address account, address token, uint256 needAmount) internal {\n Account.Props storage tradeAccount = Account.load(account);\n if (tradeAccount.getTokenAmount(token) < needAmount) {\n revert Errors.MintFailedWithBalanceNotEnough(account, token);\n }\n tradeAccount.subTokenIgnoreUsedAmount(token, needAmount);\n int256 availableValue = tradeAccount.getCrossAvailableValue();\n if (\n availableValue < 0\n ) {\n revert Errors.MintFailedWithBalanceNotEnough(account, token);\n }\n }\n\n function computeStakeAmountFromMintToken(\n LpPool.Props storage pool,\n uint256 mintAmount\n ) public view returns (uint256) {\n uint256 totalSupply = TokenUtils.totalSupply(pool.stakeToken);\n uint8 tokenDecimals = TokenUtils.decimals(pool.baseToken);\n uint256 poolValue = pool.getPoolValue();\n uint256 mintStakeTokenAmount;\n if (totalSupply == 0 && poolValue == 0) {\n mintStakeTokenAmount = mintAmount;\n } else if (totalSupply == 0 && poolValue > 0) {\n mintStakeTokenAmount =\n mintAmount +\n CalUtils.usdToToken(\n poolValue,\n tokenDecimals,\n OracleProcess.getLatestUsdUintPrice(pool.baseToken, true)\n );\n } else if (poolValue == 0) {\n revert Errors.PoolValueIsZero();\n } else {\n uint256 baseMintAmountInUsd = CalUtils.tokenToUsd(\n mintAmount,\n tokenDecimals,\n OracleProcess.getLatestUsdUintPrice(pool.baseToken, true)\n );\n mintStakeTokenAmount = totalSupply.mul(baseMintAmountInUsd).div(poolValue);\n }\n return mintStakeTokenAmount;\n }\n}\n" + }, + "contracts/process/OracleProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"../storage/OracleFeed.sol\";\nimport \"../storage/OraclePrice.sol\";\nimport \"../utils/AddressUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary OracleProcess {\n using OraclePrice for OraclePrice.Props;\n using SafeCast for int256;\n\n struct OracleParam {\n address token;\n address targetToken;\n int256 minPrice;\n int256 maxPrice;\n }\n\n function setOraclePrice(OracleParam[] calldata params) external {\n OraclePrice.Props storage oracle = OraclePrice.load();\n for (uint256 i; i < params.length; i++) {\n if (params[i].targetToken == address(0)) {\n oracle.setPrice(params[i].token, OraclePrice.Data(params[i].minPrice, params[i].maxPrice));\n } else {\n oracle.setPrice(\n params[i].token,\n params[i].targetToken,\n OraclePrice.Data(params[i].minPrice, params[i].maxPrice)\n );\n }\n }\n }\n\n function getIntOraclePrices(OracleParam[] memory params, address token, bool isMin) external view returns (int256) {\n for (uint256 i; i < params.length; i++) {\n if (params[i].token == token) {\n return isMin ? params[i].minPrice : params[i].maxPrice;\n }\n }\n return getLatestUsdPrice(token, isMin);\n }\n\n function getIntOraclePrices(\n OracleParam[] memory params,\n address token,\n address targetToken,\n bool isMin\n ) external view returns (int256) {\n for (uint256 i; i < params.length; i++) {\n if (params[i].token == token && params[i].targetToken == targetToken) {\n return isMin ? params[i].minPrice : params[i].maxPrice;\n }\n }\n return getLatestUsdPrice(token, targetToken, isMin);\n }\n\n function getOraclePrices(OracleParam[] memory params, address token, bool isMin) external view returns (uint256) {\n for (uint256 i; i < params.length; i++) {\n if (params[i].token == token) {\n return isMin ? uint256(params[i].minPrice) : uint256(params[i].maxPrice);\n }\n }\n return getLatestUsdUintPrice(token, isMin);\n }\n\n function getOraclePrices(\n OracleParam[] memory params,\n address token,\n address targetToken,\n bool isMin\n ) external view returns (uint256) {\n for (uint256 i; i < params.length; i++) {\n if (params[i].token == token) {\n return isMin ? uint256(params[i].minPrice) : uint256(params[i].maxPrice);\n }\n }\n return getLatestUsdUintPrice(token, targetToken, isMin);\n }\n\n function clearOraclePrice() external {\n OraclePrice.load().clearAllPrice();\n }\n\n function getLatestUsdUintPrice(address token, address targetToken, bool min) public view returns (uint256) {\n return getLatestUsdPrice(token, targetToken, min).toUint256();\n }\n\n function getLatestUsdPrice(address token, address targetToken, bool min) public view returns (int256) {\n OraclePrice.Props storage oracle = OraclePrice.load();\n OraclePrice.Data memory tokenPrice = oracle.getPrice(token, targetToken);\n if (tokenPrice.min == 0 || tokenPrice.max == 0) {\n revert Errors.PriceIsZero();\n }\n return min ? tokenPrice.min : tokenPrice.max;\n }\n\n function getLatestUsdPrice(address token, bool min) public view returns (int256) {\n OraclePrice.Data memory data = _getLatestUsdPriceWithOracle(token);\n return min ? data.min : data.max;\n }\n\n function getLatestUsdUintPrice(address token, bool min) public view returns (uint256) {\n OraclePrice.Data memory data = _getLatestUsdPriceWithOracle(token);\n return min ? uint256(data.min) : uint256(data.max);\n }\n\n function getLatestUsdPrice(address token) public view returns (OraclePrice.Data memory) {\n return _getLatestUsdPriceWithOracle(token);\n }\n\n function getLatestUsdUintPrice(address token) public view returns (uint256 min, uint256 max) {\n OraclePrice.Data memory data = _getLatestUsdPriceWithOracle(token);\n return (uint256(data.min), uint256(data.max));\n }\n\n function _getLatestUsdPriceWithOracle(address token) internal view returns (OraclePrice.Data memory) {\n OraclePrice.Props storage oracle = OraclePrice.load();\n OraclePrice.Data memory tokenPrice = oracle.getPrice(token);\n if (tokenPrice.min == 0 || tokenPrice.max == 0) {\n revert Errors.PriceIsZero();\n }\n return tokenPrice;\n }\n}\n" + }, + "contracts/process/OrderProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"../interfaces/IAccount.sol\";\nimport \"../interfaces/IOrder.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/Order.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../vault/TradeVault.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/AddressUtils.sol\";\nimport \"../utils/CommonUtils.sol\";\nimport \"./DecreasePositionProcess.sol\";\nimport \"./IncreasePositionProcess.sol\";\nimport \"./AccountProcess.sol\";\nimport \"./AssetsProcess.sol\";\nimport \"./GasProcess.sol\";\nimport \"./LpPoolProcess.sol\";\nimport \"./FeeProcess.sol\";\nimport \"./VaultProcess.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary OrderProcess {\n using Config for Config.Props;\n using Order for Order.Props;\n using Position for Position.Props;\n using IncreasePositionProcess for Position.Props;\n using DecreasePositionProcess for Position.Props;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n using Symbol for Symbol.Props;\n using SafeMath for uint256;\n\n bytes32 constant ORDER_ID_KEY = keccak256(\"ORDER_ID_KEY\");\n\n event PlaceOrderEvent(uint256 indexed orderId, Order.OrderInfo data);\n event OrderFilledEvent(uint256 indexed orderId, Order.OrderInfo data, uint256 fillTime, uint256 fillPrice);\n event CancelOrderEvent(uint256 indexed orderId, Order.OrderInfo data, bytes32 reasonCode);\n\n struct ExecuteOrderParams {\n uint256 orderId;\n address keeper;\n }\n\n struct ExecuteIncreaseOrderCache {\n uint256 executionPrice;\n uint256 orderMargin;\n uint256 orderMarginFromBalance;\n address marginToken;\n uint256 marginTokenPrice;\n bool isLong;\n }\n\n event ExecuteOrderStartEvent(\n uint256 orderId,\n bytes32 symbol,\n address marginToken,\n bool updateLongOrShortPosition,\n uint256 marginTokenPrice,\n uint256 updateTimestamp\n );\n\n function createOrderRequest(\n Account.Props storage accountProps,\n IOrder.PlaceOrderParams calldata params,\n bool validateExecutionFee\n ) external {\n _validatePlaceOrder(params);\n if (\n params.posSide == Order.PositionSide.INCREASE &&\n params.orderSide == Order.Side.SHORT &&\n (PositionQueryProcess.hasOtherShortPosition(\n accountProps.owner,\n params.symbol,\n params.marginToken,\n params.isCrossMargin\n ) ||\n Order.hasOtherShortOrders(\n accountProps.getAllOrders(),\n params.symbol,\n params.marginToken,\n params.isCrossMargin\n ))\n ) {\n revert Errors.OnlyOneShortPositionSupport(params.symbol);\n }\n\n (uint256 orderMargin, bool isExecutionFeeFromTradeVault) = validateExecutionFee\n ? _validateGasFeeLimitAndInitialMargin(accountProps, params)\n : (params.orderMargin, false);\n\n uint256 orderId = UuidCreator.nextId(ORDER_ID_KEY);\n Order.OrderInfo storage order = Order.create(orderId);\n order.account = accountProps.owner;\n order.symbol = params.symbol;\n order.orderSide = params.orderSide;\n order.posSide = params.posSide;\n order.orderType = params.orderType;\n order.marginToken = params.marginToken;\n order.orderMargin = orderMargin;\n order.qty = params.qty;\n order.triggerPrice = params.triggerPrice;\n order.acceptablePrice = params.acceptablePrice;\n order.stopType = params.stopType;\n order.isCrossMargin = params.isCrossMargin;\n order.isExecutionFeeFromTradeVault = isExecutionFeeFromTradeVault;\n order.executionFee = params.executionFee;\n order.leverage = params.leverage;\n order.placeTime = params.placeTime;\n order.lastBlock = ChainUtils.currentBlock();\n if (Order.PositionSide.INCREASE == params.posSide && order.isCrossMargin) {\n accountProps.addOrderHoldInUsd(orderMargin);\n }\n accountProps.addOrder(orderId);\n emit PlaceOrderEvent(orderId, order);\n }\n\n function executeOrder(uint256 orderId, Order.OrderInfo memory order) external {\n Config.Props storage config = Config.load();\n\n // verify block no\n if (Order.Type.MARKET == order.orderType) {\n CommonUtils.validBlockNumber(\n order.lastBlock,\n config.tradeConfig.executeOrderMinBlockGap,\n config.tradeConfig.executeOrderMaxBlockGap\n );\n } else if (Order.Type.LIMIT == order.orderType) {\n CommonUtils.validMinBlockNumber(order.lastBlock, config.tradeConfig.executeOrderMinBlockGap);\n }\n\n Symbol.Props memory symbolProps = Symbol.load(order.symbol);\n\n _validExecuteOrder(order, symbolProps);\n if (Order.PositionSide.INCREASE == order.posSide) {\n _executeIncreaseOrder(orderId, order, symbolProps);\n } else if (Order.PositionSide.DECREASE == order.posSide) {\n _executeDecreaseOrder(orderId, order, symbolProps);\n }\n Order.remove(orderId);\n }\n\n function _executeIncreaseOrder(\n uint256 orderId,\n Order.OrderInfo memory order,\n Symbol.Props memory symbolProps\n ) internal {\n if (\n order.posSide == Order.PositionSide.INCREASE &&\n order.orderSide == Order.Side.SHORT &&\n PositionQueryProcess.hasOtherShortPosition(\n order.account,\n order.symbol,\n order.marginToken,\n order.isCrossMargin\n )\n ) {\n revert Errors.OnlyOneShortPositionSupport(order.symbol);\n }\n Account.Props storage accountProps = Account.load(order.account);\n\n ExecuteIncreaseOrderCache memory cache;\n cache.isLong = Order.Side.LONG == order.orderSide;\n\n emit ExecuteOrderStartEvent(\n orderId,\n symbolProps.code,\n order.marginToken,\n cache.isLong,\n OracleProcess.getLatestUsdUintPrice(order.marginToken, !cache.isLong),\n ChainUtils.currentTimestamp()\n );\n\n MarketProcess.updateMarketFundingFeeRate(symbolProps.code);\n MarketProcess.updatePoolBorrowingFeeRate(symbolProps.stakeToken, cache.isLong, order.marginToken);\n\n cache.executionPrice = _getExecutionPrice(order, symbolProps.indexToken);\n if (symbolProps.indexToken == order.marginToken) {\n cache.marginTokenPrice = cache.executionPrice;\n } else {\n cache.marginTokenPrice = OracleProcess.getLatestUsdUintPrice(order.marginToken, !cache.isLong);\n }\n\n (cache.orderMargin, cache.orderMarginFromBalance) = _executeIncreaseOrderMargin(\n order,\n accountProps,\n cache.marginTokenPrice\n );\n\n if (!order.isCrossMargin) {\n VaultProcess.transferOut(\n IVault(address(this)).getTradeVaultAddress(),\n order.marginToken,\n symbolProps.stakeToken,\n cache.orderMargin\n );\n }\n\n Position.Props storage positionProps = Position.load(\n order.account,\n symbolProps.code,\n order.marginToken,\n order.isCrossMargin\n );\n if (positionProps.qty == 0) {\n if (\n accountProps.hasOtherOrder(orderId) &&\n getOrderLeverage(\n accountProps,\n symbolProps.code,\n order.orderSide,\n order.isCrossMargin,\n order.leverage\n ) !=\n order.leverage\n ) {\n revert Errors.UpdateLeverageError(\n order.account,\n symbolProps.code,\n Order.Side.LONG == order.orderSide,\n getOrderLeverage(\n accountProps,\n symbolProps.code,\n order.orderSide,\n order.isCrossMargin,\n order.leverage\n ),\n order.leverage\n );\n }\n bytes32 key = Position.getPositionKey(\n order.account,\n symbolProps.code,\n order.marginToken,\n order.isCrossMargin\n );\n positionProps.key = key;\n positionProps.account = order.account;\n positionProps.indexToken = symbolProps.indexToken;\n positionProps.symbol = symbolProps.code;\n positionProps.marginToken = order.marginToken;\n positionProps.leverage = order.leverage;\n positionProps.isLong = cache.isLong;\n positionProps.isCrossMargin = order.isCrossMargin;\n accountProps.addPosition(key);\n } else if (positionProps.leverage != order.leverage) {\n revert Errors.UpdateLeverageError(\n order.account,\n symbolProps.code,\n Order.Side.LONG == order.orderSide,\n positionProps.leverage,\n order.leverage\n );\n }\n positionProps.increasePosition(\n symbolProps,\n IncreasePositionProcess.IncreasePositionParams(\n orderId,\n order.marginToken,\n cache.orderMargin,\n cache.orderMarginFromBalance,\n cache.marginTokenPrice,\n cache.executionPrice,\n order.leverage,\n cache.isLong,\n order.isCrossMargin\n )\n );\n accountProps.delOrder(orderId);\n\n emit OrderFilledEvent(orderId, order, block.timestamp, cache.executionPrice);\n }\n\n function _getExecutionPrice(Order.OrderInfo memory order, address indexToken) internal view returns (uint256) {\n bool isMinPrice;\n if (Order.PositionSide.INCREASE == order.posSide) {\n isMinPrice = Order.Side.SHORT == order.orderSide;\n } else {\n isMinPrice = Order.Side.LONG == order.orderSide;\n }\n if (Order.Type.MARKET == order.orderType) {\n uint256 indexPrice = OracleProcess.getLatestUsdUintPrice(indexToken, isMinPrice);\n if (\n (isMinPrice && order.acceptablePrice > 0 && indexPrice < order.acceptablePrice) ||\n (!isMinPrice && order.acceptablePrice > 0 && indexPrice > order.acceptablePrice)\n ) {\n revert Errors.ExecutionPriceInvalid();\n }\n return indexPrice;\n }\n uint256 currentPrice = OracleProcess.getLatestUsdUintPrice(indexToken, isMinPrice);\n bool isLong = Order.Side.LONG == order.orderSide;\n if (\n Order.Type.LIMIT == order.orderType ||\n (Order.Type.STOP == order.orderType && Order.StopType.TAKE_PROFIT == order.stopType)\n ) {\n if ((isLong && order.triggerPrice >= currentPrice) || (!isLong && order.triggerPrice <= currentPrice)) {\n return currentPrice;\n }\n revert Errors.ExecutionPriceInvalid();\n }\n if (Order.Type.STOP == order.orderType && Order.StopType.STOP_LOSS == order.stopType) {\n if ((isLong && order.triggerPrice <= currentPrice) || (!isLong && order.triggerPrice >= currentPrice)) {\n return currentPrice;\n }\n revert Errors.ExecutionPriceInvalid();\n }\n revert Errors.ExecutionPriceInvalid();\n }\n\n function _executeIncreaseOrderMargin(\n Order.OrderInfo memory order,\n Account.Props storage accountProps,\n uint256 marginTokenPrice\n ) internal returns (uint256 orderMargin, uint256 orderMarginFromBalance) {\n address marginToken = order.marginToken;\n address account = accountProps.owner;\n if (order.isCrossMargin) {\n if (accountProps.getCrossAvailableValue() < 0) {\n revert Errors.BalanceNotEnough(account, marginToken);\n }\n if (order.orderMargin < Config.load().getTradeConfig().minOrderMarginUSD) {\n revert Errors.OrderMarginTooSmall();\n }\n orderMargin = CalUtils.usdToToken(order.orderMargin, TokenUtils.decimals(marginToken), marginTokenPrice);\n accountProps.subOrderHoldInUsd(order.orderMargin);\n orderMarginFromBalance = accountProps.useToken(marginToken, orderMargin);\n } else {\n uint256 orderMarginInUsd = CalUtils.tokenToUsd(\n order.orderMargin,\n TokenUtils.decimals(marginToken),\n marginTokenPrice\n );\n if (orderMarginInUsd < Config.load().getTradeConfig().minOrderMarginUSD) {\n revert Errors.OrderMarginTooSmall();\n }\n orderMargin = order.orderMargin;\n orderMarginFromBalance = order.orderMargin;\n }\n }\n\n function _isUserPlaceOrder(Order.Type orderType) internal pure returns (bool) {\n return Order.Type.LIMIT == orderType || Order.Type.MARKET == orderType || Order.Type.STOP == orderType;\n }\n\n function _validExecuteOrder(Order.OrderInfo memory order, Symbol.Props memory symbolProps) internal view {\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(symbolProps.code);\n bool isIncrease = Order.PositionSide.INCREASE == order.posSide;\n bool isLong = Order.Side.LONG == order.orderSide;\n if (_isUserPlaceOrder(order.orderType) && isIncrease && Symbol.Status.OPEN != symbolProps.status) {\n revert Errors.SymbolStatusInvalid(order.symbol);\n }\n\n // token verify\n if (isIncrease) {\n if (isLong && order.marginToken != symbolProps.baseToken) {\n revert Errors.TokenInvalid(order.symbol, order.marginToken);\n }\n if (!isLong && !UsdPool.isSupportStableToken(order.marginToken)) {\n revert Errors.TokenInvalid(order.symbol, order.marginToken);\n }\n }\n\n if (order.leverage > symbolConfig.maxLeverage || order.leverage < 1 * CalUtils.RATE_PRECISION) {\n revert Errors.LeverageInvalid(order.symbol, order.leverage);\n }\n }\n\n function getOrderLeverage(\n Account.Props storage accountProps,\n bytes32 symbol,\n Order.Side orderSide,\n bool isCrossMargin,\n uint256 defaultLeverage\n ) internal view returns (uint256) {\n uint256[] memory orders = accountProps.getAllOrders();\n Order.Props storage orderProps = Order.load();\n for (uint256 i; i < orders.length; i++) {\n Order.OrderInfo memory orderInfo = orderProps.get(orders[i]);\n if (\n orderInfo.symbol == symbol &&\n orderInfo.orderSide == orderSide &&\n orderInfo.isCrossMargin == isCrossMargin\n ) {\n return orderInfo.leverage;\n }\n }\n return defaultLeverage;\n }\n\n function _validatePlaceOrder(IOrder.PlaceOrderParams calldata params) internal view {\n if (\n Order.Type.MARKET != params.orderType &&\n Order.Type.LIMIT != params.orderType &&\n Order.Type.STOP != params.orderType\n ) {\n revert Errors.PlaceOrderWithParamsError();\n }\n\n if (Order.PositionSide.DECREASE == params.posSide && params.qty == 0) {\n revert Errors.PlaceOrderWithParamsError();\n }\n\n if (Order.Side.NONE == params.orderSide) {\n revert Errors.PlaceOrderWithParamsError();\n }\n\n if (Order.Type.LIMIT == params.orderType && params.triggerPrice == 0) {\n revert Errors.PlaceOrderWithParamsError();\n }\n\n if (Order.Type.LIMIT == params.orderType && Order.PositionSide.DECREASE == params.posSide) {\n revert Errors.PlaceOrderWithParamsError();\n }\n\n if (\n Order.Type.STOP == params.orderType && (Order.StopType.NONE == params.stopType || params.triggerPrice == 0)\n ) {\n revert Errors.PlaceOrderWithParamsError();\n }\n\n if (Order.PositionSide.INCREASE == params.posSide) {\n if (params.orderMargin == 0) {\n console.log(\"params.orderMargin\", params.orderMargin);\n revert Errors.PlaceOrderWithParamsError();\n }\n Symbol.Props storage symbolProps = Symbol.load(params.symbol);\n if (!symbolProps.isSupportIncreaseOrder()) {\n revert Errors.SymbolStatusInvalid(params.symbol);\n }\n if (Order.Side.LONG == params.orderSide && params.marginToken != symbolProps.baseToken) {\n revert Errors.PlaceOrderWithParamsError();\n }\n if (Order.Side.SHORT == params.orderSide && !UsdPool.isSupportStableToken(params.marginToken)) {\n revert Errors.PlaceOrderWithParamsError();\n }\n }\n }\n\n function _executeDecreaseOrder(\n uint256 orderId,\n Order.OrderInfo memory order,\n Symbol.Props memory symbolProps\n ) internal {\n address account = order.account;\n bool isLong = Order.Side.LONG == order.orderSide;\n\n Position.Props storage position = Position.load(account, order.symbol, order.marginToken, order.isCrossMargin);\n position.checkExists();\n\n if (Order.Type.MARKET == order.orderType && position.qty < order.qty) {\n revert Errors.DecreaseQtyTooBig(symbolProps.code, position.account);\n }\n if (position.qty > order.qty && position.qty - order.qty < Config.load().getTradeConfig().minOrderMarginUSD) {\n revert Errors.ReducePositionTooSmall(symbolProps.code, position.account);\n }\n if (position.isLong == isLong) {\n revert Errors.DecreaseOrderSideInvalid();\n }\n\n if (Order.Type.STOP == order.orderType && position.qty < order.qty) {\n order.qty = position.qty;\n }\n\n emit ExecuteOrderStartEvent(\n orderId,\n symbolProps.code,\n order.marginToken,\n position.isLong,\n OracleProcess.getLatestUsdUintPrice(order.marginToken, position.isLong),\n ChainUtils.currentTimestamp()\n );\n\n MarketProcess.updateMarketFundingFeeRate(symbolProps.code);\n MarketProcess.updatePoolBorrowingFeeRate(symbolProps.stakeToken, position.isLong, order.marginToken);\n\n uint256 executionPrice = _getExecutionPrice(order, symbolProps.indexToken);\n\n position.decreasePosition(\n DecreasePositionProcess.DecreasePositionParams(\n orderId,\n order.symbol,\n false,\n false,\n order.marginToken,\n order.qty,\n executionPrice\n )\n );\n Account.load(order.account).delOrder(orderId);\n emit OrderFilledEvent(orderId, order, block.timestamp, executionPrice);\n }\n\n function _validateGasFeeLimitAndInitialMargin(\n Account.Props storage accountProps,\n IOrder.PlaceOrderParams calldata params\n ) internal returns (uint256, bool) {\n Config.ChainConfig memory chainConfig = Config.getChainConfig();\n uint256 configGasFeeLimit = Order.PositionSide.INCREASE == params.posSide\n ? chainConfig.placeIncreaseOrderGasFeeLimit\n : chainConfig.placeDecreaseOrderGasFeeLimit;\n GasProcess.validateExecutionFeeLimit(params.executionFee, configGasFeeLimit);\n if (\n params.isNativeToken &&\n params.posSide == Order.PositionSide.INCREASE &&\n !params.isCrossMargin &&\n params.orderMargin >= params.executionFee\n ) {\n return (params.orderMargin - params.executionFee, true);\n }\n require(msg.value == params.executionFee, \"place order with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n accountProps.owner,\n chainConfig.wrapperToken,\n params.executionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n return (params.orderMargin, false);\n }\n\n function _validateBatchGasFeeLimit(\n Account.Props storage accountProps,\n IOrder.PlaceOrderParams calldata params\n ) internal returns (uint256, bool) {\n Config.ChainConfig memory chainConfig = Config.getChainConfig();\n uint256 configGasFeeLimit = Order.PositionSide.INCREASE == params.posSide\n ? chainConfig.placeIncreaseOrderGasFeeLimit\n : chainConfig.placeDecreaseOrderGasFeeLimit;\n GasProcess.validateExecutionFeeLimit(params.executionFee, configGasFeeLimit);\n if (\n params.isNativeToken &&\n params.posSide == Order.PositionSide.INCREASE &&\n !params.isCrossMargin &&\n params.orderMargin >= params.executionFee\n ) {\n accountProps.subTokenIgnoreUsedAmount(chainConfig.wrapperToken, params.executionFee);\n return (params.orderMargin - params.executionFee, true);\n }\n require(msg.value == params.executionFee, \"place order with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n accountProps.owner,\n chainConfig.wrapperToken,\n params.executionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n return (params.orderMargin, false);\n }\n}\n" + }, + "contracts/process/PositionMarginProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/IPosition.sol\";\nimport \"../storage/Position.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/UpdatePositionMargin.sol\";\nimport \"../storage/UpdateLeverage.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../storage/Order.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"../utils/CommonUtils.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./LpPoolProcess.sol\";\nimport \"./FeeProcess.sol\";\nimport \"./VaultProcess.sol\";\nimport \"./AccountProcess.sol\";\n\nlibrary PositionMarginProcess {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedSafeMath for int256;\n using Math for uint256;\n using Config for Config.Props;\n using Position for Position.Props;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n\n bytes32 constant UPDATE_MARGIN_ID_KEY = keccak256(\"UPDATE_MARGIN_ID_KEY\");\n bytes32 constant UPDATE_LEVERAGE_ID_KEY = keccak256(\"UPDATE_LEVERAGE_ID_KEY\");\n\n event CreateUpdateLeverageEvent(uint256 indexed requestId, UpdateLeverage.Request data);\n event CreateUpdatePositionMarginEvent(uint256 indexed requestId, UpdatePositionMargin.Request data);\n event UpdatePositionMarginSuccessEvent(uint256 indexed requestId, UpdatePositionMargin.Request data);\n event UpdateLeverageSuccessEvent(uint256 indexed requestId, UpdateLeverage.Request data);\n event CancelUpdateLeverageEvent(uint256 indexed requestId, UpdateLeverage.Request data, bytes32 reasonCode);\n event CancelUpdatePositionMarginEvent(\n uint256 indexed requestId,\n UpdatePositionMargin.Request data,\n bytes32 reasonCode\n );\n\n struct AddPositionMarginCache {\n address stakeToken;\n uint256 addMarginAmount;\n uint256 marginTokenPrice;\n uint8 marginTokenDecimals;\n bool isCrossMargin;\n uint256 addInitialMarginFromBalance;\n }\n\n function createUpdatePositionMarginRequest(\n address account,\n IPosition.UpdatePositionMarginParams memory params,\n uint256 updateMarginAmount,\n bool isExecutionFeeFromTradeVault\n ) external {\n uint256 requestId = UuidCreator.nextId(UPDATE_MARGIN_ID_KEY);\n UpdatePositionMargin.Request storage request = UpdatePositionMargin.create(requestId);\n request.account = account;\n request.positionKey = params.positionKey;\n request.marginToken = params.marginToken;\n request.updateMarginAmount = updateMarginAmount;\n request.isAdd = params.isAdd;\n request.isExecutionFeeFromTradeVault = isExecutionFeeFromTradeVault;\n request.executionFee = params.executionFee;\n request.lastBlock = ChainUtils.currentBlock();\n emit CreateUpdatePositionMarginEvent(requestId, request);\n }\n\n function createUpdateLeverageRequest(\n address account,\n IPosition.UpdateLeverageParams memory params,\n uint256 addMarginAmount,\n bool isExecutionFeeFromTradeVault\n ) external {\n uint256 requestId = UuidCreator.nextId(UPDATE_LEVERAGE_ID_KEY);\n UpdateLeverage.Request storage request = UpdateLeverage.create(requestId);\n request.account = account;\n request.symbol = params.symbol;\n request.marginToken = params.marginToken;\n request.addMarginAmount = addMarginAmount;\n request.leverage = params.leverage;\n request.isLong = params.isLong;\n request.isExecutionFeeFromTradeVault = isExecutionFeeFromTradeVault;\n request.executionFee = params.executionFee;\n request.lastBlock = ChainUtils.currentBlock();\n request.isCrossMargin = params.isCrossMargin;\n\n emit CreateUpdateLeverageEvent(requestId, request);\n }\n\n function updatePositionMargin(uint256 requestId, UpdatePositionMargin.Request memory request) external {\n Config.Props storage config = Config.load();\n CommonUtils.validBlockNumber(\n request.lastBlock,\n config.tradeConfig.executePositionMarginMinBlockGap,\n config.tradeConfig.executePositionMarginMaxBlockGap\n );\n Position.Props storage position = Position.load(request.positionKey);\n position.checkExists();\n if (position.isCrossMargin) {\n revert Errors.OnlyIsolateSupported();\n }\n Symbol.Props memory symbolProps = Symbol.load(position.symbol);\n Account.Props storage accountProps = Account.load(request.account);\n if (request.isAdd) {\n AddPositionMarginCache memory cache;\n cache.stakeToken = symbolProps.stakeToken;\n cache.addMarginAmount = request.updateMarginAmount;\n cache.marginTokenDecimals = TokenUtils.decimals(position.marginToken);\n cache.marginTokenPrice = OracleProcess.getLatestUsdUintPrice(position.marginToken, !position.isLong);\n cache.isCrossMargin = false;\n _executeAddMargin(position, cache);\n VaultProcess.transferOut(\n IVault(address(this)).getTradeVaultAddress(),\n request.marginToken,\n symbolProps.stakeToken,\n cache.addMarginAmount\n );\n position.emitPositionUpdateEvent(requestId, Position.PositionUpdateFrom.ADD_MARGIN, 0);\n } else {\n uint256 reduceMarginAmount = _executeReduceMargin(\n position,\n symbolProps,\n config,\n request.updateMarginAmount,\n true\n );\n VaultProcess.transferOut(symbolProps.stakeToken, request.marginToken, request.account, reduceMarginAmount);\n position.emitPositionUpdateEvent(requestId, Position.PositionUpdateFrom.DECREASE_MARGIN, 0);\n }\n Order.updateAllOrderLeverage(\n accountProps.getAllOrders(),\n position.symbol,\n position.marginToken,\n position.leverage,\n position.isLong,\n position.isCrossMargin\n );\n\n emit UpdatePositionMarginSuccessEvent(requestId, request);\n }\n\n function updatePositionLeverage(uint256 requestId, UpdateLeverage.Request memory request) external {\n Config.Props storage config = Config.load();\n CommonUtils.validBlockNumber(\n request.lastBlock,\n config.tradeConfig.executeLeverageMinBlockGap,\n config.tradeConfig.executeLeverageMaxBlockGap\n );\n bytes32 positionKey = Position.getPositionKey(\n request.account,\n request.symbol,\n request.marginToken,\n request.isCrossMargin\n );\n\n Position.Props storage position = Position.load(positionKey);\n if (position.leverage == request.leverage) {\n revert Errors.UpdateLeverageWithNoChange();\n }\n\n Symbol.Props memory symbolProps = Symbol.load(request.symbol);\n Account.Props storage accountProps = Account.load(request.account);\n\n if (position.qty != 0) {\n if (position.leverage > request.leverage) {\n AddPositionMarginCache memory cache;\n cache.stakeToken = symbolProps.stakeToken;\n cache.marginTokenDecimals = TokenUtils.decimals(request.marginToken);\n cache.marginTokenPrice = OracleProcess.getLatestUsdUintPrice(position.marginToken, !position.isLong);\n cache.isCrossMargin = position.isCrossMargin;\n if (cache.isCrossMargin) {\n position.leverage = request.leverage;\n uint256 newInitialMarginInUsd = CalUtils.divRate(position.qty, position.leverage);\n uint256 addMarginInUsd = newInitialMarginInUsd > position.initialMarginInUsd\n ? newInitialMarginInUsd - position.initialMarginInUsd\n : 0;\n if (addMarginInUsd.toInt256() > accountProps.getCrossAvailableValue()) {\n revert Errors.BalanceNotEnough(request.account, position.marginToken);\n }\n cache.addMarginAmount = CalUtils.usdToToken(\n addMarginInUsd,\n cache.marginTokenDecimals,\n cache.marginTokenPrice\n );\n cache.addInitialMarginFromBalance = CalUtils.tokenToUsd(\n cache.addMarginAmount.min(accountProps.getAvailableTokenAmount(position.marginToken)),\n cache.marginTokenDecimals,\n cache.marginTokenPrice\n );\n accountProps.useToken(position.marginToken, cache.addMarginAmount);\n } else {\n cache.addMarginAmount = request.addMarginAmount;\n }\n _executeAddMargin(position, cache);\n if (!cache.isCrossMargin) {\n VaultProcess.transferOut(\n IVault(address(this)).getTradeVaultAddress(),\n position.marginToken,\n symbolProps.stakeToken,\n cache.addMarginAmount\n );\n }\n position.emitPositionUpdateEvent(requestId, Position.PositionUpdateFrom.DECREASE_LEVERAGE, 0);\n } else {\n position.leverage = request.leverage;\n uint256 reduceMargin = position.initialMarginInUsd - CalUtils.divRate(position.qty, position.leverage);\n uint256 reduceMarginAmount = _executeReduceMargin(position, symbolProps, config, reduceMargin, false);\n if (position.isCrossMargin) {\n accountProps.unUseToken(position.marginToken, reduceMarginAmount);\n } else {\n VaultProcess.transferOut(\n symbolProps.stakeToken,\n request.marginToken,\n request.account,\n reduceMarginAmount\n );\n }\n position.emitPositionUpdateEvent(requestId, Position.PositionUpdateFrom.INCREASE_LEVERAGE, 0);\n }\n }\n\n Order.updateAllOrderLeverage(\n accountProps.getAllOrders(),\n request.symbol,\n request.marginToken,\n request.leverage,\n request.isLong,\n request.isCrossMargin\n );\n\n emit UpdateLeverageSuccessEvent(requestId, request);\n }\n\n function cancelUpdatePositionMarginRequest(\n uint256 requestId,\n UpdatePositionMargin.Request memory request,\n bytes32 reasonCode\n ) external {\n if (request.isAdd) {\n VaultProcess.transferOut(\n IVault(address(this)).getTradeVaultAddress(),\n request.marginToken,\n request.account,\n request.updateMarginAmount\n );\n }\n UpdatePositionMargin.remove(requestId);\n\n emit CancelUpdatePositionMarginEvent(requestId, request, reasonCode);\n }\n\n function cancelUpdateLeverageRequest(\n uint256 requestId,\n UpdateLeverage.Request memory request,\n bytes32 reasonCode\n ) external {\n bytes32 positionKey = Position.getPositionKey(\n request.account,\n request.symbol,\n request.marginToken,\n request.isCrossMargin\n );\n Position.Props storage position = Position.load(positionKey);\n if (request.addMarginAmount > 0 && !position.isCrossMargin) {\n VaultProcess.transferOut(\n IVault(address(this)).getTradeVaultAddress(),\n request.marginToken,\n request.account,\n request.addMarginAmount\n );\n }\n UpdateLeverage.remove(requestId);\n\n emit CancelUpdateLeverageEvent(requestId, request, reasonCode);\n }\n\n function _executeAddMargin(Position.Props storage position, AddPositionMarginCache memory cache) internal {\n if (\n cache.addMarginAmount >\n CalUtils.usdToToken(\n position.qty - position.initialMarginInUsd,\n cache.marginTokenDecimals,\n cache.marginTokenPrice\n )\n ) {\n revert Errors.AddMarginTooBig();\n }\n position.initialMargin += cache.addMarginAmount;\n if (cache.isCrossMargin) {\n position.initialMarginInUsd = CalUtils.divRate(position.qty, position.leverage);\n position.initialMarginInUsdFromBalance += cache.addInitialMarginFromBalance;\n } else {\n position.initialMarginInUsd += CalUtils.tokenToUsd(\n cache.addMarginAmount,\n cache.marginTokenDecimals,\n cache.marginTokenPrice\n );\n position.leverage = CalUtils.divRate(position.qty, position.initialMarginInUsd);\n position.initialMarginInUsdFromBalance = position.initialMarginInUsd;\n }\n\n uint256 subHoldAmount = cache.addMarginAmount.min(position.holdPoolAmount);\n position.holdPoolAmount -= subHoldAmount;\n LpPoolProcess.updatePnlAndUnHoldPoolAmount(cache.stakeToken, position.marginToken, subHoldAmount, 0, 0);\n }\n\n function _executeReduceMargin(\n Position.Props storage position,\n Symbol.Props memory symbolProps,\n Config.Props storage config,\n uint256 reduceMargin,\n bool needUpdateLeverage\n ) internal returns (uint256) {\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(symbolProps.code);\n uint256 maxReduceMarginInUsd = position.initialMarginInUsd -\n CalUtils.divRate(position.qty, symbolConfig.maxLeverage).max(config.tradeConfig.minOrderMarginUSD);\n if (reduceMargin > maxReduceMarginInUsd) {\n revert Errors.ReduceMarginTooBig();\n }\n uint8 decimals = TokenUtils.decimals(position.marginToken);\n uint256 marginTokenPrice = OracleProcess.getLatestUsdUintPrice(position.marginToken, !position.isLong);\n uint256 reduceMarginAmount = CalUtils.usdToToken(reduceMargin, decimals, marginTokenPrice);\n position.initialMargin -= reduceMarginAmount;\n position.initialMarginInUsd -= reduceMargin;\n if (needUpdateLeverage) {\n position.leverage = CalUtils.divRate(position.qty, position.initialMarginInUsd);\n }\n position.initialMarginInUsdFromBalance = position.initialMarginInUsd;\n position.holdPoolAmount += reduceMarginAmount;\n LpPoolProcess.holdPoolAmount(symbolProps.stakeToken, position.marginToken, reduceMarginAmount, position.isLong);\n return reduceMarginAmount;\n }\n}\n" + }, + "contracts/process/PositionQueryProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\n\nimport \"../storage/Position.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Symbol.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./MarketQueryProcess.sol\";\n\nlibrary PositionQueryProcess {\n using Math for uint256;\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SignedSafeMath for int256;\n using SafeCast for int256;\n using Config for Config.Props;\n using Account for Account.Props;\n\n struct ComputePositionFeeCache {\n int256 posFundingFeeInUsd;\n uint256 posBorrowingFeeInUsd;\n uint8 tokenDecimal;\n int256 fundingFeePerQty;\n int256 unRealizedFundingFeeDelta;\n uint256 cumulativeBorrowingFeePerToken;\n uint256 unRealizedBorrowingFeeDelta;\n }\n\n struct PositionStaticsCache {\n int256 totalPnl;\n uint256 totalIMUsd;\n uint256 totalIMUsdFromBalance;\n uint256 totalMM;\n int256 totalPosFee;\n uint256 totalQty;\n }\n\n function hasOtherShortPosition(\n address account,\n bytes32 symbol,\n address marginToken,\n bool isCrossMargin\n ) external view returns (bool) {\n address[] memory stableTokens = UsdPool.getSupportedStableTokens();\n for (uint256 i; i < stableTokens.length; i++) {\n if (stableTokens[i] == marginToken) {\n continue;\n }\n Position.Props storage position = Position.load(account, symbol, stableTokens[i], isCrossMargin);\n if (position.qty > 0) {\n return true;\n }\n }\n return false;\n }\n\n function getPositionUnPnl(\n Position.Props memory position,\n int256 computeIndexPrice,\n bool pnlToken\n ) public view returns (int256) {\n OracleProcess.OracleParam[] memory oracles;\n return getPositionUnPnl(position, oracles, computeIndexPrice, pnlToken);\n }\n\n function getPositionUnPnl(\n Position.Props memory position,\n OracleProcess.OracleParam[] memory oracles,\n int256 computeIndexPrice,\n bool pnlToken\n ) public view returns (int256) {\n (int256 pnlInToken, int256 pnlInUsd) = getPositionUnPnl(position, oracles, computeIndexPrice);\n return pnlToken ? pnlInToken : pnlInUsd;\n }\n\n function getPositionUnPnl(\n Position.Props memory position,\n OracleProcess.OracleParam[] memory oracles,\n int256 computeIndexPrice\n ) public view returns (int256, int256) {\n if (position.qty == 0) {\n return (0, 0);\n }\n if (position.isLong) {\n int pnlInUsd = position.qty.toInt256().mul(computeIndexPrice.sub(position.entryPrice.toInt256())).div(\n position.entryPrice.toInt256()\n );\n return (\n CalUtils.usdToTokenInt(pnlInUsd, TokenUtils.decimals(position.marginToken), computeIndexPrice),\n pnlInUsd\n );\n } else {\n int pnlInUsd = position.qty.toInt256().mul(position.entryPrice.toInt256().sub(computeIndexPrice)).div(\n position.entryPrice.toInt256()\n );\n int256 marginTokenPrice = OracleProcess.getIntOraclePrices(oracles, position.marginToken, false);\n return (\n CalUtils.usdToTokenInt(pnlInUsd, TokenUtils.decimals(position.marginToken), marginTokenPrice),\n pnlInUsd\n );\n }\n }\n\n function getLiquidationPrice(Position.Props storage position) external view returns (uint256) {\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(position.symbol);\n uint256 mmInUsd = getMM(position.qty, symbolConfig.maxLeverage, Config.getTradeMaxMaintenanceMarginRate());\n int256 posFee = getPositionFee(position);\n int256 positionValue = position.isLong\n ? (position.qty - position.initialMarginInUsd + mmInUsd).toInt256() + posFee\n : (position.qty + position.initialMarginInUsd - mmInUsd).toInt256() - posFee;\n if (positionValue < 0) {\n return 0;\n }\n uint256 liquidationPrice = positionValue.toUint256().mul(position.entryPrice).div(position.qty);\n return CalUtils.formatToTickSize(liquidationPrice, symbolConfig.tickSize, position.isLong);\n }\n\n function getPositionMMRate(Position.Props memory position) public view returns (uint256) {\n uint256 maxMaintenanceMarginRate = Config.getTradeMaxMaintenanceMarginRate();\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(position.symbol);\n return CalUtils.divRate(CalUtils.RATE_PRECISION, symbolConfig.maxLeverage.mul(2)).min(maxMaintenanceMarginRate);\n }\n\n function getMM(uint256 qty, uint256 leverage, uint256 maxMMRate) public pure returns (uint256) {\n return CalUtils.divRate(qty, leverage.mul(2)).min(CalUtils.mulRate(qty, maxMMRate));\n }\n\n function getPositionMM(Position.Props memory position) public view returns (uint256) {\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(position.symbol);\n uint256 maxMaintenanceMarginRate = Config.getTradeMaxMaintenanceMarginRate();\n return getMM(position.qty, symbolConfig.maxLeverage, maxMaintenanceMarginRate);\n }\n\n function getAllPosition(\n Account.Props storage accountProps,\n bool isCrossMargin\n ) public view returns (Position.Props[] memory) {\n bytes32[] memory positionKeys = accountProps.getAllPosition();\n Position.Props[] memory positions = new Position.Props[](_getPositionIndex(positionKeys, isCrossMargin));\n uint256 positionIndex;\n for (uint256 i; i < positionKeys.length; i++) {\n Position.Props memory position = Position.load(positionKeys[i]);\n if (position.isCrossMargin == isCrossMargin) {\n positions[positionIndex] = position;\n positionIndex += 1;\n }\n }\n\n return positions;\n }\n\n function getPositionFee(Position.Props memory position) public view returns (int256) {\n OracleProcess.OracleParam[] memory oracles;\n return getPositionFee(position, oracles);\n }\n\n function getPositionFee(\n Position.Props memory position,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (int256) {\n ComputePositionFeeCache memory cache;\n cache.fundingFeePerQty = MarketQueryProcess.getFundingFeePerQty(position.symbol, position.isLong);\n cache.unRealizedFundingFeeDelta = CalUtils.mulIntSmallRate(\n position.qty.toInt256(),\n (cache.fundingFeePerQty - position.positionFee.openFundingFeePerQty)\n );\n cache.tokenDecimal = TokenUtils.decimals(position.marginToken);\n if (position.isLong) {\n cache.posFundingFeeInUsd =\n position.positionFee.realizedFundingFeeInUsd +\n CalUtils.tokenToUsdInt(\n cache.unRealizedFundingFeeDelta,\n cache.tokenDecimal,\n OracleProcess.getIntOraclePrices(oracles, position.marginToken, position.isLong)\n );\n } else {\n cache.posFundingFeeInUsd = position.positionFee.realizedFundingFeeInUsd + cache.unRealizedFundingFeeDelta;\n }\n\n Symbol.Props memory symbolProps = Symbol.load(position.symbol);\n cache.cumulativeBorrowingFeePerToken = MarketQueryProcess.getCumulativeBorrowingFeePerToken(\n symbolProps.stakeToken,\n position.isLong,\n position.marginToken\n );\n cache.unRealizedBorrowingFeeDelta = CalUtils.mulSmallRate(\n CalUtils.mulRate(position.initialMargin, position.leverage - CalUtils.RATE_PRECISION),\n cache.cumulativeBorrowingFeePerToken - position.positionFee.openBorrowingFeePerToken\n );\n\n cache.posBorrowingFeeInUsd =\n position.positionFee.realizedBorrowingFeeInUsd +\n CalUtils.tokenToUsd(\n cache.unRealizedBorrowingFeeDelta,\n cache.tokenDecimal,\n OracleProcess.getOraclePrices(oracles, position.marginToken, position.isLong)\n );\n consoleInt(\"cache.fundingFeePerQty\", cache.fundingFeePerQty);\n consoleInt(\"realizedFundingFeeInUsd\", position.positionFee.realizedFundingFeeInUsd);\n consoleInt(\"unRealizedFundingFeeDelta\", cache.unRealizedFundingFeeDelta);\n consoleInt(\"posFundingFeeInUsd\", cache.posFundingFeeInUsd);\n console.log(\"cumulativeBorrowingFeePerToken\", cache.cumulativeBorrowingFeePerToken);\n console.log(\"realizedBorrowingFeeInUsd\", position.positionFee.realizedBorrowingFeeInUsd);\n console.log(\"unRealizedBorrowingFeeDelta\", cache.unRealizedBorrowingFeeDelta);\n console.log(\"posBorrowingFeeInUsd\", cache.posBorrowingFeeInUsd);\n console.log(\"closeFeeInUsd\", position.positionFee.closeFeeInUsd);\n return\n position.positionFee.closeFeeInUsd.toInt256() +\n cache.posFundingFeeInUsd +\n cache.posBorrowingFeeInUsd.toInt256();\n }\n\n function consoleInt(string memory code, int256 value) internal pure {\n if (value >= 0) {\n console.log(code, value.toUint256());\n } else {\n console.log(\"-\", code, (-value).toUint256());\n }\n }\n\n function getAccountAllCrossPositionValue(\n Account.Props storage accountProps\n ) public view returns (PositionStaticsCache memory) {\n OracleProcess.OracleParam[] memory cache;\n return getAccountAllCrossPositionValue(accountProps, cache);\n }\n\n function getAccountAllCrossPositionValue(\n Account.Props storage accountProps,\n OracleProcess.OracleParam[] memory oracles\n ) public view returns (PositionStaticsCache memory cache) {\n accountProps.checkExists();\n Position.Props[] memory allCrossPositions = getAllPosition(accountProps, true);\n\n Config.Props storage config = Config.load();\n uint256 maxMaintenanceMarginRate = config.tradeConfig.maxMaintenanceMarginRate;\n for (uint256 i; i < allCrossPositions.length; i++) {\n Position.Props memory position = allCrossPositions[i];\n int256 indexTokenPrice = OracleProcess.getIntOraclePrices(oracles, position.indexToken, position.isLong);\n Config.SymbolConfig memory symbolConfig = Config.load().getSymbolConfig(position.symbol);\n int256 unPnl = getPositionUnPnl(position, oracles, indexTokenPrice, false);\n if (unPnl > 0) {\n cache.totalPnl = cache.totalPnl.add(\n CalUtils.mulRate(unPnl, config.getTradeCollateralDiscount(position.marginToken).toInt256())\n );\n } else {\n cache.totalPnl = cache.totalPnl.add(\n CalUtils.mulRate(\n unPnl,\n (CalUtils.RATE_PRECISION + config.getTradeCollateralLiquidationFactor(position.marginToken))\n .toInt256()\n )\n );\n }\n\n cache.totalMM = cache.totalMM.add(getMM(position.qty, symbolConfig.maxLeverage, maxMaintenanceMarginRate));\n cache.totalIMUsd = cache.totalIMUsd.add(position.initialMarginInUsd);\n cache.totalIMUsdFromBalance = cache.totalIMUsdFromBalance.add(position.initialMarginInUsdFromBalance);\n cache.totalQty = cache.totalQty.add(position.qty);\n cache.totalPosFee = cache.totalPosFee.add(getPositionFee(position, oracles));\n }\n }\n\n function _getPositionIndex(bytes32[] memory positionKeys, bool isCrossMargin) internal pure returns (uint256) {\n uint256 positionIndex;\n Position.Props memory position;\n for (uint256 i; i < positionKeys.length; i++) {\n position = Position.load(positionKeys[i]);\n if (position.isCrossMargin == isCrossMargin) {\n positionIndex += 1;\n }\n }\n\n return positionIndex;\n }\n}\n" + }, + "contracts/process/RebalanceProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\";\nimport \"@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol\";\nimport \"../interfaces/IRebalance.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"./VaultProcess.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./SwapProcess.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/CommonData.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary RebalanceProcess {\n using LpPool for LpPool.Props;\n using UsdPool for UsdPool.Props;\n using CommonData for CommonData.Props;\n using SafeCast for uint256;\n using SafeCast for int256;\n\n struct RebalanceUnsettleCache {\n int256[] poolUnsettledAmount;\n int256 totalUnsettledAmount;\n uint256[] settledAmount;\n int256 tokenLiability;\n uint256 reduceTransferAmount;\n }\n\n function autoRebalance() external {\n address[] memory stakeTokens = CommonData.getAllStakeTokens();\n for (uint256 i; i < stakeTokens.length; i++) {\n LpPool.Props storage pool = LpPool.load(stakeTokens[i]);\n console.log(i, \"_rebalanceUnsettle baseToken\", pool.baseToken);\n _rebalanceUnsettle(pool.baseToken, false, stakeTokens);\n }\n address[] memory stableTokens = UsdPool.getSupportedStableTokens();\n for (uint256 i; i < stableTokens.length; i++) {\n console.log(i, \"_rebalanceUnsettle stableTokens\", stableTokens[i]);\n _rebalanceUnsettle(stableTokens[i], true, stakeTokens);\n }\n for (uint256 i; i < stakeTokens.length; i++) {\n console.log(i, \"_rebalanceStableTokens stakeTokens[i]\", stakeTokens[i]);\n _rebalanceStableTokens(stakeTokens[i]);\n }\n }\n\n function _rebalanceStableTokens(address stakeToken) internal {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n address[] memory tokens = pool.getStableTokens();\n int256[] memory netStableTokenAmount = new int256[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n LpPool.TokenBalance storage tokenBalance = pool.getStableTokenBalance(tokens[i]);\n netStableTokenAmount[i] = tokenBalance.amount >= tokenBalance.lossAmount\n ? (tokenBalance.amount - tokenBalance.lossAmount).toInt256()\n : -(tokenBalance.lossAmount - tokenBalance.amount).toInt256();\n }\n for (uint256 i; i < netStableTokenAmount.length; i++) {\n if (netStableTokenAmount[i] == 0) {\n continue;\n }\n if (netStableTokenAmount[i] < 0) {\n uint256 tokenNetStableTokenAmount = (-netStableTokenAmount[i]).toUint256();\n for (uint8 j = 0; j < netStableTokenAmount.length; j++) {\n if (netStableTokenAmount[j] <= 0) {\n continue;\n }\n uint256 reduceProfitTokenAmount = netStableTokenAmount[j].toUint256();\n uint256 offsetLossStableTokenAmount = CalUtils.tokenToToken(\n reduceProfitTokenAmount,\n TokenUtils.decimals(tokens[j]),\n TokenUtils.decimals(tokens[i]),\n OracleProcess.getLatestUsdUintPrice(tokens[j], true),\n OracleProcess.getLatestUsdUintPrice(tokens[i], false)\n );\n \n if (offsetLossStableTokenAmount > tokenNetStableTokenAmount) {\n offsetLossStableTokenAmount = tokenNetStableTokenAmount;\n reduceProfitTokenAmount = CalUtils.tokenToToken(\n tokenNetStableTokenAmount,\n TokenUtils.decimals(tokens[i]),\n TokenUtils.decimals(tokens[j]),\n OracleProcess.getLatestUsdUintPrice(tokens[i], false),\n OracleProcess.getLatestUsdUintPrice(tokens[j], true)\n );\n }\n netStableTokenAmount[i] = netStableTokenAmount[i] + offsetLossStableTokenAmount.toInt256();\n netStableTokenAmount[j] = netStableTokenAmount[j] - reduceProfitTokenAmount.toInt256();\n if (netStableTokenAmount[i] >= 0) {\n break;\n }\n }\n }\n }\n\n UsdPool.Props storage usdPool = UsdPool.load();\n address stakeUsd = CommonData.getStakeUsdToken();\n for (uint256 i; i < netStableTokenAmount.length; i++) {\n LpPool.TokenBalance storage tokenBalance = pool.getStableTokenBalance(tokens[i]);\n if (netStableTokenAmount[i] == 0) {\n usdPool.settleStableToken(tokens[i], tokenBalance.lossAmount, true);\n usdPool.addStableToken(\n tokens[i],\n tokenBalance.amount > tokenBalance.lossAmount ? tokenBalance.amount - tokenBalance.lossAmount : 0\n );\n VaultProcess.transferOut(stakeToken, tokens[i], stakeUsd, tokenBalance.amount);\n tokenBalance.amount = 0;\n tokenBalance.lossAmount = 0;\n } else if (netStableTokenAmount[i] > 0) {\n usdPool.settleStableToken(tokens[i], tokenBalance.lossAmount, true);\n usdPool.addStableToken(\n tokens[i],\n tokenBalance.amount - netStableTokenAmount[i].toUint256() > tokenBalance.lossAmount\n ? tokenBalance.amount - netStableTokenAmount[i].toUint256() - tokenBalance.lossAmount\n : 0\n );\n VaultProcess.transferOut(\n stakeToken,\n tokens[i],\n stakeUsd,\n tokenBalance.amount > netStableTokenAmount[i].toUint256() ? tokenBalance.amount - netStableTokenAmount[i].toUint256() : 0\n );\n ISwap.SwapSingleResult memory swapResult = _swapToBaseToken(\n stakeToken,\n tokens[i],\n netStableTokenAmount[i].toUint256(),\n pool.baseToken\n );\n pool.subStableToken(tokens[i], swapResult.reduceFromAmount);\n pool.addBaseToken(swapResult.toTokenAmount);\n\n tokenBalance.amount = netStableTokenAmount[i].toUint256() - swapResult.reduceFromAmount;\n tokenBalance.lossAmount = 0;\n } else {\n ISwap.SwapSingleResult memory swapResult = _swapToStableTokens(\n stakeToken,\n pool.baseToken,\n tokens[i],\n (-netStableTokenAmount[i]).toUint256()\n );\n pool.subBaseToken(swapResult.reduceFromAmount);\n pool.addStableToken(tokens[i], swapResult.toTokenAmount);\n\n usdPool.settleStableToken(\n tokens[i],\n tokenBalance.lossAmount + swapResult.toTokenAmount - (-netStableTokenAmount[i]).toUint256(),\n true\n );\n VaultProcess.transferOut(\n stakeToken,\n tokens[i],\n stakeUsd,\n tokenBalance.amount + swapResult.toTokenAmount\n );\n tokenBalance.amount = 0;\n tokenBalance.lossAmount = (-netStableTokenAmount[i]).toUint256() - swapResult.toTokenAmount;\n }\n }\n }\n\n function _swapToBaseToken(\n address stakeToken,\n address fromToken,\n uint256 fromAmount,\n address toToken\n ) internal returns (ISwap.SwapSingleResult memory) {\n uint256 toTokenAmount = CalUtils.tokenToToken(\n fromAmount,\n TokenUtils.decimals(fromToken),\n TokenUtils.decimals(toToken),\n OracleProcess.getLatestUsdUintPrice(fromToken, true),\n OracleProcess.getLatestUsdUintPrice(toToken, false)\n );\n toTokenAmount -= CalUtils.mulRate(toTokenAmount, Config.load().tradeConfig.swapSlipperTokenFactor);\n return\n SwapProcess.singleSwap(\n ISwap.SwapSingleParam(stakeToken, fromToken, fromAmount, toTokenAmount, toToken, stakeToken)\n );\n }\n\n function _swapToStableTokens(\n address stakeToken,\n address fromToken,\n address toToken,\n uint256 toAmount\n ) internal returns (ISwap.SwapSingleResult memory) {\n uint256 needTokenAmount = CalUtils.tokenToToken(\n toAmount,\n TokenUtils.decimals(toToken),\n TokenUtils.decimals(fromToken),\n OracleProcess.getLatestUsdUintPrice(toToken, true),\n OracleProcess.getLatestUsdUintPrice(fromToken, false)\n );\n needTokenAmount += CalUtils.mulRate(needTokenAmount, Config.load().tradeConfig.swapSlipperTokenFactor);\n return\n SwapProcess.singleSwap(\n ISwap.SwapSingleParam(stakeToken, fromToken, needTokenAmount, toAmount, toToken, stakeToken)\n );\n }\n\n function _rebalanceUnsettle(address token, bool isStableToken, address[] memory stakeTokens) internal {\n if (\n (isStableToken && !UsdPool.isSupportStableToken(token)) ||\n (!isStableToken && UsdPool.isSupportStableToken(token))\n ) {\n return;\n }\n RebalanceUnsettleCache memory cache;\n cache.poolUnsettledAmount = new int256[](stakeTokens.length);\n for (uint256 i; i < stakeTokens.length; i++) {\n LpPool.Props storage pool = LpPool.load(stakeTokens[i]);\n if (isStableToken) {\n cache.poolUnsettledAmount[i] = pool.getStableTokenBalance(token).unsettledAmount;\n } else {\n cache.poolUnsettledAmount[i] = token == pool.baseToken\n ? pool.baseTokenBalance.unsettledAmount\n : int256(0);\n }\n\n if (cache.poolUnsettledAmount[i] <= 0) {\n continue;\n }\n cache.totalUnsettledAmount += cache.poolUnsettledAmount[i];\n }\n if (cache.totalUnsettledAmount <= 0) {\n return;\n }\n cache.settledAmount = new uint256[](stakeTokens.length);\n cache.tokenLiability = CommonData.load().getTokenLiability(token).toInt256();\n if (cache.totalUnsettledAmount > cache.tokenLiability) {\n uint256 totalTransferAmount = cache.totalUnsettledAmount.toUint256() - cache.tokenLiability.toUint256();\n cache.reduceTransferAmount = totalTransferAmount;\n address portfolioVaultAddress = IVault(address(this)).getPortfolioVaultAddress();\n\n for (uint256 i; i < stakeTokens.length; i++) {\n if (cache.poolUnsettledAmount[i] == 0) {\n continue;\n }\n LpPool.Props storage pool = LpPool.load(stakeTokens[i]);\n if (i == stakeTokens.length - 1) {\n cache.settledAmount[i] = cache.reduceTransferAmount;\n cache.reduceTransferAmount = 0;\n } else {\n cache.settledAmount[i] = CalUtils.divToPrecision(\n totalTransferAmount,\n cache.totalUnsettledAmount.toUint256(),\n cache.poolUnsettledAmount[i].toUint256()\n );\n cache.reduceTransferAmount -= cache.settledAmount[i];\n }\n if (isStableToken) {\n pool.settleStableToken(token, cache.settledAmount[i]);\n } else {\n pool.settleBaseToken(cache.settledAmount[i]);\n }\n VaultProcess.transferOut(portfolioVaultAddress, token, stakeTokens[i], cache.settledAmount[i]);\n }\n }\n }\n}\n" + }, + "contracts/process/RedeemProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"../interfaces/IVault.sol\";\nimport \"../interfaces/IStake.sol\";\nimport \"../vault/Vault.sol\";\nimport \"../vault/LpVault.sol\";\nimport \"../vault/StakeToken.sol\";\nimport \"../storage/Config.sol\";\nimport \"../storage/StakingAccount.sol\";\nimport \"../storage/Account.sol\";\nimport \"../storage/LpPool.sol\";\nimport \"../storage/UsdPool.sol\";\nimport \"../storage/Redeem.sol\";\nimport \"../storage/UuidCreator.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/TokenUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"./OracleProcess.sol\";\nimport \"./GasProcess.sol\";\nimport \"./LpPoolProcess.sol\";\nimport \"./LpPoolQueryProcess.sol\";\nimport \"./FeeRewardsProcess.sol\";\nimport \"./VaultProcess.sol\";\nimport \"./AccountProcess.sol\";\nimport \"./AssetsProcess.sol\";\nimport \"./MintProcess.sol\";\nimport \"./FeeQueryProcess.sol\";\n\nlibrary RedeemProcess {\n using LpPool for LpPool.Props;\n using LpPoolProcess for LpPool.Props;\n using LpPoolQueryProcess for LpPool.Props;\n using UsdPool for UsdPool.Props;\n using LpPoolProcess for UsdPool.Props;\n using LpPoolQueryProcess for UsdPool.Props;\n using StakingAccount for StakingAccount.Props;\n using Account for Account.Props;\n using AccountProcess for Account.Props;\n using Config for Config.Props;\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n\n bytes32 constant REDEEM_ID_KEY = keccak256(\"REDEEM_ID_KEY\");\n\n struct ExecuteRedeemCache {\n uint256 poolValue;\n uint256 totalSupply;\n uint8 tokenDecimals;\n uint256 unStakeUsd;\n uint256 redeemTokenAmount;\n uint256 redeemFee;\n }\n\n event CreateRedeemEvent(uint256 indexed requestId, Redeem.Request data);\n event RedeemSuccessEvent(uint256 indexed requestId, uint256 redeemTokenAmount, Redeem.Request data);\n event CancelRedeemEvent(uint256 indexed requestId, Redeem.Request data, bytes32 reasonCode);\n\n function createRedeemStakeTokenRequest(\n IStake.RedeemStakeTokenParams memory params,\n address account,\n uint256 unStakeAmount\n ) external {\n uint256 requestId = UuidCreator.nextId(REDEEM_ID_KEY);\n\n Redeem.Request storage redeemRequest = Redeem.create(requestId);\n redeemRequest.account = account;\n redeemRequest.receiver = params.receiver;\n redeemRequest.stakeToken = params.stakeToken;\n redeemRequest.redeemToken = params.redeemToken;\n redeemRequest.unStakeAmount = unStakeAmount;\n redeemRequest.minRedeemAmount = params.minRedeemAmount;\n redeemRequest.executionFee = params.executionFee;\n\n emit CreateRedeemEvent(requestId, redeemRequest);\n }\n\n function executeRedeemStakeToken(uint256 requestId, Redeem.Request memory redeemRequest) external {\n uint256 redeemAmount;\n if (redeemRequest.receiver == address(0)) {\n revert Errors.RedeemRequestNotExists();\n }\n if (CommonData.getStakeUsdToken() == redeemRequest.stakeToken) {\n redeemAmount = _redeemStakeUsd(redeemRequest);\n } else if (CommonData.isStakeTokenSupport(redeemRequest.stakeToken)) {\n redeemAmount = _redeemStakeToken(redeemRequest);\n } else {\n revert Errors.StakeTokenInvalid(redeemRequest.stakeToken);\n }\n\n FeeRewardsProcess.updateAccountFeeRewards(redeemRequest.account, redeemRequest.stakeToken);\n\n Redeem.remove(requestId);\n\n emit RedeemSuccessEvent(requestId, redeemAmount, redeemRequest);\n }\n\n function autoRedeemStakeCollateral(\n LpPool.Props storage pool,\n StakingAccount.Props storage stakingAccountProps,\n address collateral\n ) external {\n address account = stakingAccountProps.owner;\n StakingAccount.CollateralData memory data = stakingAccountProps.getCollateralToken(pool.stakeToken, collateral);\n Account.Props storage accountProps = Account.load(account);\n _updateRedeemCollateral(stakingAccountProps, accountProps, pool, collateral, data.amount, data.stakeLiability);\n uint256 unStakeAmount = MintProcess.computeStakeAmountFromMintToken(pool, data.stakeLiability);\n StakeToken(pool.stakeToken).burn(account, unStakeAmount);\n stakingAccountProps.subStakeAmount(pool.stakeToken, unStakeAmount);\n }\n\n function cancelRedeemStakeToken(\n uint256 requestId,\n Redeem.Request memory redeemRequest,\n bytes32 reasonCode\n ) external {\n Redeem.remove(requestId);\n emit CancelRedeemEvent(requestId, redeemRequest, reasonCode);\n }\n\n function validateAndDepositRedeemExecutionFee(address account, uint256 executionFee) external {\n Config.Props storage config = Config.load();\n GasProcess.validateExecutionFeeLimit(executionFee, config.chainConfig.redeemGasFeeLimit);\n require(msg.value == executionFee, \"redeem with execution fee error!\");\n AssetsProcess.depositToVault(\n AssetsProcess.DepositParams(\n account,\n config.chainConfig.wrapperToken,\n executionFee,\n AssetsProcess.DepositFrom.MANUAL,\n true\n )\n );\n }\n\n function _redeemStakeToken(Redeem.Request memory params) internal returns (uint256 redeemTokenAmount) {\n LpPool.Props storage pool = LpPool.load(params.stakeToken);\n if (pool.baseToken != params.redeemToken) {\n revert Errors.RedeemTokenInvalid(params.stakeToken, params.redeemToken);\n }\n redeemTokenAmount = _executeRedeemStakeToken(pool, params, params.redeemToken);\n }\n\n function _redeemStakeUsd(Redeem.Request memory params) internal returns (uint256 redeemTokenAmount) {\n address stakeUsdToken = params.stakeToken;\n address account = params.account;\n uint256 stakeTokenAmount = StakeToken(stakeUsdToken).balanceOf(account);\n if (stakeTokenAmount < params.unStakeAmount) {\n revert Errors.RedeemWithAmountNotEnough(account, stakeUsdToken);\n }\n\n UsdPool.Props storage pool = UsdPool.load();\n redeemTokenAmount = _executeRedeemStakeUsd(pool, stakeUsdToken, params);\n\n StakingAccount.Props storage accountProps = StakingAccount.load(account);\n accountProps.subStakeUsdAmount(params.unStakeAmount);\n pool.subStableToken(params.redeemToken, redeemTokenAmount);\n }\n\n function _executeRedeemStakeToken(\n LpPool.Props storage pool,\n Redeem.Request memory params,\n address baseToken\n ) internal returns (uint256) {\n ExecuteRedeemCache memory cache;\n cache.poolValue = pool.getPoolValue();\n cache.totalSupply = TokenUtils.totalSupply(pool.stakeToken);\n cache.tokenDecimals = TokenUtils.decimals(baseToken);\n if (cache.poolValue == 0 || cache.totalSupply == 0) {\n revert Errors.RedeemWithAmountNotEnough(params.account, baseToken);\n }\n\n cache.unStakeUsd = params.unStakeAmount.mul(cache.poolValue).div(cache.totalSupply);\n cache.redeemTokenAmount = CalUtils.usdToToken(\n cache.unStakeUsd,\n cache.tokenDecimals,\n OracleProcess.getLatestUsdUintPrice(baseToken, false)\n );\n\n if (pool.getPoolAvailableLiquidity() < cache.redeemTokenAmount) {\n revert Errors.RedeemWithAmountNotEnough(params.account, params.redeemToken);\n }\n\n if (params.minRedeemAmount > 0 && cache.redeemTokenAmount < params.minRedeemAmount) {\n revert Errors.RedeemStakeTokenTooSmall(cache.redeemTokenAmount);\n }\n\n Account.Props storage accountProps = Account.load(params.account);\n StakingAccount.Props storage stakingAccountProps = StakingAccount.load(params.account);\n Config.LpPoolConfig storage poolConfig = Config.load().getPoolConfig(pool.stakeToken);\n if (stakingAccountProps.hasCollateralToken(params.stakeToken)) {\n address[] memory collateralTokens = stakingAccountProps.getSortedCollateralToken(params.stakeToken);\n uint256 reduceRedeemTokenAmount = cache.redeemTokenAmount;\n for (uint256 i; i < collateralTokens.length; i++) {\n StakingAccount.CollateralData memory data = stakingAccountProps.getCollateralToken(\n params.stakeToken,\n collateralTokens[i]\n );\n if (reduceRedeemTokenAmount >= data.stakeLiability) {\n _updateRedeemCollateral(\n stakingAccountProps,\n accountProps,\n pool,\n collateralTokens[i],\n data.amount,\n data.stakeLiability\n );\n reduceRedeemTokenAmount -= data.stakeLiability;\n } else {\n uint256 transferCollateralAmount = data.amount.mul(reduceRedeemTokenAmount).div(\n data.stakeLiability\n );\n _updateRedeemCollateral(\n stakingAccountProps,\n accountProps,\n pool,\n collateralTokens[i],\n transferCollateralAmount,\n reduceRedeemTokenAmount\n );\n reduceRedeemTokenAmount = 0;\n }\n\n if (reduceRedeemTokenAmount == 0) {\n break;\n }\n }\n if (reduceRedeemTokenAmount > 0) {\n pool.subPoolAmount(pool.baseToken, reduceRedeemTokenAmount);\n\n uint256 redeemFee = FeeQueryProcess.calcMintOrRedeemFee(\n reduceRedeemTokenAmount,\n poolConfig.redeemFeeRate\n );\n FeeProcess.chargeMintOrRedeemFee(\n redeemFee,\n params.stakeToken,\n params.redeemToken,\n params.account,\n FeeProcess.FEE_REDEEM,\n false\n );\n if (Config.load().isTradeCollateralSupport(params.redeemToken)) {\n accountProps.addToken(params.redeemToken, reduceRedeemTokenAmount - redeemFee);\n VaultProcess.transferOut(\n params.stakeToken,\n params.redeemToken,\n address(IVault(address(this)).getPortfolioVault()),\n reduceRedeemTokenAmount - redeemFee\n );\n } else {\n VaultProcess.transferOut(\n params.stakeToken,\n params.redeemToken,\n params.receiver,\n reduceRedeemTokenAmount - redeemFee\n );\n }\n }\n } else {\n uint256 redeemFee = FeeQueryProcess.calcMintOrRedeemFee(cache.redeemTokenAmount, poolConfig.redeemFeeRate);\n FeeProcess.chargeMintOrRedeemFee(\n redeemFee,\n params.stakeToken,\n params.redeemToken,\n params.account,\n FeeProcess.FEE_REDEEM,\n false\n );\n if (Config.load().isTradeCollateralSupport(params.redeemToken)) {\n accountProps.addToken(params.redeemToken, cache.redeemTokenAmount - cache.redeemFee);\n VaultProcess.transferOut(\n params.stakeToken,\n params.redeemToken,\n address(IVault(address(this)).getPortfolioVault()),\n cache.redeemTokenAmount - cache.redeemFee\n );\n } else {\n VaultProcess.transferOut(\n params.stakeToken,\n params.redeemToken,\n params.receiver,\n cache.redeemTokenAmount - cache.redeemFee\n );\n }\n pool.subPoolAmount(pool.baseToken, cache.redeemTokenAmount);\n }\n StakeToken(params.stakeToken).burn(params.account, params.unStakeAmount);\n stakingAccountProps.subStakeAmount(params.stakeToken, params.unStakeAmount);\n\n return cache.redeemTokenAmount;\n }\n\n function _executeRedeemStakeUsd(\n UsdPool.Props storage pool,\n address stakeUsdToken,\n Redeem.Request memory params\n ) internal returns (uint256) {\n address account = params.account;\n uint256 poolValue = pool.getUsdPoolValue();\n uint256 totalSupply = TokenUtils.totalSupply(stakeUsdToken);\n if (poolValue == 0 || totalSupply == 0) {\n revert Errors.RedeemWithAmountNotEnough(account, params.redeemToken);\n }\n uint8 tokenDecimals = TokenUtils.decimals(params.redeemToken);\n uint256 unStakeUsd = params.unStakeAmount.mul(poolValue).div(totalSupply);\n uint256 redeemTokenAmount = CalUtils.usdToToken(\n unStakeUsd,\n tokenDecimals,\n OracleProcess.getLatestUsdUintPrice(params.redeemToken, false)\n );\n if (params.minRedeemAmount > 0 && redeemTokenAmount < params.minRedeemAmount) {\n revert Errors.RedeemStakeTokenTooSmall(redeemTokenAmount);\n }\n if (pool.getMaxWithdraw(params.redeemToken) < redeemTokenAmount) {\n revert Errors.RedeemWithAmountNotEnough(params.account, params.redeemToken);\n }\n\n uint256 redeemFee = FeeQueryProcess.calcMintOrRedeemFee(\n redeemTokenAmount,\n Config.load().getUsdPoolConfig().redeemFeeRate\n );\n FeeProcess.chargeMintOrRedeemFee(\n redeemFee,\n params.stakeToken,\n params.redeemToken,\n params.account,\n FeeProcess.FEE_REDEEM,\n false\n );\n\n StakeToken(params.stakeToken).burn(account, params.unStakeAmount);\n StakeToken(params.stakeToken).transferOut(params.redeemToken, params.receiver, redeemTokenAmount - redeemFee);\n return redeemTokenAmount;\n }\n\n function _updateRedeemCollateral(\n StakingAccount.Props storage stakingAccountProps,\n Account.Props storage accountProps,\n LpPool.Props storage pool,\n address token,\n uint256 amount,\n uint256 stakeLiability\n ) internal {\n stakingAccountProps.subCollateralToken(pool.stakeToken, token, amount);\n stakingAccountProps.subStakeLiability(pool.stakeToken, token, stakeLiability);\n pool.subCollateralBaseToken(stakeLiability, token, amount);\n uint256 redeemFee = FeeQueryProcess.calcMintOrRedeemFee(\n amount,\n Config.load().getPoolConfig(pool.stakeToken).redeemFeeRate\n );\n FeeProcess.chargeMintOrRedeemFee(redeemFee, pool.stakeToken, token, accountProps.owner, FeeProcess.FEE_REDEEM, true);\n\n accountProps.addToken(token, amount - redeemFee);\n }\n}\n" + }, + "contracts/process/SwapProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\";\nimport \"@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"../storage/Config.sol\";\nimport \"./VaultProcess.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary SwapProcess {\n function swap(ISwap.SwapParams calldata params) external returns (ISwap.SwapResult memory result) {\n result.fromTokens = params.fromTokens;\n result.toToken = params.toToken;\n result.expectToTokenAmount = params.toTokenAmount;\n address uniswapRouter = Config.getUniswapRouter();\n for (uint256 i; i < params.fromTokens.length; i++) {\n VaultProcess.transferOut(\n params.fromTokenAddress,\n params.fromTokens[i],\n address(this),\n params.fromAmounts[i],\n false\n );\n TransferHelper.safeApprove(params.fromTokens[i], uniswapRouter, params.fromAmounts[i]);\n console.log(\"start swap\");\n ISwapRouter.ExactInputSingleParams memory callSwapParams = ISwapRouter.ExactInputSingleParams({\n tokenIn: params.fromTokens[i],\n tokenOut: params.toToken,\n fee: 3000,\n recipient: params.toTokenAddress,\n deadline: block.timestamp,\n amountIn: params.fromAmounts[i],\n amountOutMinimum: params.minToTokenAmounts[i],\n sqrtPriceLimitX96: 0\n });\n uint256 amountOut = ISwapRouter(uniswapRouter).exactInputSingle(callSwapParams);\n console.log(\"end swap\");\n result.toTokenAmount += amountOut;\n result.reduceFromAmounts[i] = params.fromAmounts[i];\n if (result.toTokenAmount >= params.toTokenAmount) {\n break;\n }\n }\n }\n\n function singleSwap(ISwap.SwapSingleParam calldata params) external returns (ISwap.SwapSingleResult memory result) {\n result.fromToken = params.fromToken;\n result.toToken = params.toToken;\n address uniswapRouter = Config.getUniswapRouter();\n VaultProcess.transferOut(params.fromTokenAddress, params.fromToken, address(this), params.fromAmount, false);\n TransferHelper.safeApprove(params.fromToken, uniswapRouter, params.fromAmount);\n ISwapRouter.ExactInputSingleParams memory callSwapParams = ISwapRouter.ExactInputSingleParams({\n tokenIn: params.fromToken,\n tokenOut: params.toToken,\n fee: 3000,\n recipient: params.toTokenAddress,\n deadline: block.timestamp,\n amountIn: params.fromAmount,\n amountOutMinimum: params.minToTokenAmount,\n sqrtPriceLimitX96: 0\n });\n uint256 amountOut = ISwapRouter(uniswapRouter).exactInputSingle(callSwapParams);\n result.toTokenAmount = amountOut;\n result.reduceFromAmount = params.fromAmount;\n }\n}\n" + }, + "contracts/process/VaultProcess.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\nimport \"../interfaces/IWETH.sol\";\nimport \"../vault/Vault.sol\";\nimport \"../storage/Config.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary VaultProcess {\n using Config for Config.Props;\n\n function transferOut(address vault, address token, address receiver, uint256 amount) external returns(bool) {\n return transferOut(vault, token, receiver, amount, false);\n }\n\n function transferOut(address vault, address token, address receiver, uint256 amount, bool skipBalanceNotEnough) public returns(bool) {\n if (amount == 0) {\n return false;\n }\n uint256 tokenBalance = IERC20(token).balanceOf(vault);\n if (tokenBalance >= amount) {\n Vault(vault).transferOut(token, receiver, amount);\n return true;\n } else if (!skipBalanceNotEnough) {\n revert Errors.TransferErrorWithVaultBalanceNotEnough(vault, token, receiver, amount);\n }\n return false;\n }\n\n function withdrawEther(address receiver, uint256 amount) internal {\n address wrapperToken = Config.getWrapperToken();\n IWETH(wrapperToken).withdraw(amount);\n safeTransferETH(receiver, amount);\n }\n\n function safeTransferETH(address to, uint256 value) internal {\n (bool success, ) = to.call{ value: value }(new bytes(0));\n require(success, \"STE\");\n }\n}\n" + }, + "contracts/router/Diamond.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n*\n* Implementation of a diamond.\n/******************************************************************************/\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { LibDiamond } from \"../storage/LibDiamond.sol\";\nimport { IDiamond } from \"../interfaces/IDiamond.sol\";\nimport { IDiamondCut } from \"../interfaces/IDiamondCut.sol\";\nimport { IDiamondLoupe } from \"../interfaces/IDiamondLoupe.sol\";\nimport \"../storage/RoleAccessControl.sol\";\nimport \"hardhat/console.sol\";\n\n// When no function exists for function called\nerror FunctionNotFound(bytes4 _functionSelector);\n\ncontract Diamond {\n constructor(address _diamondCutFacet, address _diamondLoupeFacet, address _init, address owner) payable {\n RoleAccessControl.grantRole(msg.sender, RoleAccessControl.ROLE_ADMIN);\n\n IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](2);\n bytes4[] memory functionSelectors = new bytes4[](1);\n functionSelectors[0] = IDiamondCut.diamondCut.selector;\n cut[0] = IDiamond.FacetCut({\n facetAddress: _diamondCutFacet,\n action: IDiamond.FacetCutAction.Add,\n functionSelectors: functionSelectors\n });\n\n bytes4[] memory loupeFunctionSelectors = new bytes4[](4);\n loupeFunctionSelectors[0] = IDiamondLoupe.facets.selector;\n loupeFunctionSelectors[1] = IDiamondLoupe.facetAddresses.selector;\n loupeFunctionSelectors[2] = IDiamondLoupe.facetAddress.selector;\n loupeFunctionSelectors[3] = IDiamondLoupe.facetFunctionSelectors.selector;\n cut[1] = IDiamond.FacetCut({\n facetAddress: _diamondLoupeFacet,\n action: IDiamond.FacetCutAction.Add,\n functionSelectors: loupeFunctionSelectors\n });\n LibDiamond.setContractOwner(owner);\n LibDiamond.diamondCut(cut, _init, abi.encodeWithSignature(\"init()\"));\n }\n\n // Find facet for function that is called and execute the\n // function if a facet is found and return any value.\n fallback() external payable {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n // get facet from function selector\n address facet = ds.facetAddressAndSelectorPosition[msg.sig].facetAddress;\n if (facet == address(0)) {\n revert FunctionNotFound(msg.sig);\n }\n // Execute external function from facet using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the facet\n let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/router/DiamondInit.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { LibDiamond } from \"../storage/LibDiamond.sol\";\nimport { IDiamondLoupe } from \"../interfaces/IDiamondLoupe.sol\";\nimport { IDiamondCut } from \"../interfaces/IDiamondCut.sol\";\n\ncontract DiamondInit { \n\n function init() external {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n ds.supportedInterfaces[type(IERC165).interfaceId] = true;\n ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;\n ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;\n \n }\n}\n" + }, + "contracts/storage/Account.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"./CommonData.sol\";\nimport \"./Config.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary Account {\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.Bytes32Set;\n using EnumerableSet for EnumerableSet.UintSet;\n using CommonData for CommonData.Props;\n using Config for Config.Props;\n\n struct Props {\n address owner;\n uint256 orderHoldInUsd;\n EnumerableSet.AddressSet tokens;\n mapping(address => Account.TokenBalance) tokenBalances;\n EnumerableSet.Bytes32Set positions;\n EnumerableSet.UintSet orders;\n }\n\n struct TokenBalance {\n uint256 amount;\n uint256 usedAmount;\n uint256 interest;\n uint256 liability;\n }\n\n event AccountTokenUpdateEvent(address account, address token, TokenBalance preBalance, TokenBalance balance);\n\n event AccountOrderHoldInUsdUpdateEvent(address account, uint256 preOrderHoldInUsd, uint256 orderHoldInUsd);\n\n event AccountCrossModeUpdateEvent(address account, bool isCrossMargin);\n\n function load(address owner) public pure returns (Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profile.storage.Account\", owner));\n assembly {\n self.slot := s\n }\n }\n\n function loadOrCreate(address owner) public returns (Props storage) {\n Props storage self = load(owner);\n if (self.owner == address(0)) {\n self.owner = owner;\n }\n return self;\n }\n\n function addOrderHoldInUsd(Props storage self, uint256 holdInUsd) external {\n uint256 preOrderHoldInUsd = self.orderHoldInUsd;\n self.orderHoldInUsd += holdInUsd;\n emit AccountOrderHoldInUsdUpdateEvent(self.owner, preOrderHoldInUsd, self.orderHoldInUsd);\n }\n\n function subOrderHoldInUsd(Props storage self, uint256 holdInUsd) external {\n require(self.orderHoldInUsd >= holdInUsd, \"orderHoldInUsd is smaller than holdInUsd\");\n uint256 preOrderHoldInUsd = self.orderHoldInUsd;\n self.orderHoldInUsd -= holdInUsd;\n emit AccountOrderHoldInUsdUpdateEvent(self.owner, preOrderHoldInUsd, self.orderHoldInUsd);\n }\n\n function addToken(Props storage self, address token, uint256 amount, bool updateBorrow) external {\n if (!self.tokens.contains(token)) {\n self.tokens.add(token);\n }\n TokenBalance storage balance = self.tokenBalances[token];\n TokenBalance memory preBalance = balance;\n if (!updateBorrow) {\n balance.amount += amount;\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, balance);\n return;\n }\n balance.amount += amount;\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, balance);\n }\n\n function addToken(Props storage self, address token, uint256 amount) external {\n if (!self.tokens.contains(token)) {\n self.tokens.add(token);\n }\n TokenBalance storage balance = self.tokenBalances[token];\n TokenBalance memory preBalance = balance;\n balance.amount += amount;\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, balance);\n }\n\n function subToken(Props storage self, address token, uint256 amount) external {\n require(self.tokens.contains(token), \"token not exists!\");\n require(self.tokenBalances[token].amount >= amount, \"token amount not enough!\");\n require(\n self.tokenBalances[token].amount >= self.tokenBalances[token].usedAmount + amount,\n \"token amount exclude used amount not enough!\"\n );\n TokenBalance memory preBalance = self.tokenBalances[token];\n self.tokenBalances[token].amount -= amount;\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, self.tokenBalances[token]);\n }\n\n function subTokenIgnoreUsedAmount(Props storage self, address token, uint256 amount) external {\n require(self.tokens.contains(token), \"token not exists!\");\n require(self.tokenBalances[token].amount >= amount, \"token amount not enough!\");\n TokenBalance memory preBalance = self.tokenBalances[token];\n self.tokenBalances[token].amount -= amount;\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, self.tokenBalances[token]);\n }\n\n function subTokenWithLiability(\n Props storage self,\n address token,\n uint256 amount\n ) external returns (uint256 liability) {\n TokenBalance storage balance = self.tokenBalances[token];\n TokenBalance memory preBalance = balance;\n if (balance.amount >= amount) {\n balance.amount -= amount;\n liability = 0;\n } else if (balance.amount > 0) {\n liability = amount - balance.amount;\n balance.liability += liability;\n balance.usedAmount += liability;\n balance.amount = 0;\n } else {\n balance.liability += amount;\n balance.usedAmount += amount;\n liability = amount;\n }\n CommonData.load().addTokenLiability(token, liability);\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, balance);\n }\n\n function useToken(Props storage self, address token, uint256 amount) external returns (uint256 useFromBalance) {\n return useToken(self, token, amount, false);\n }\n\n function useToken(\n Props storage self,\n address token,\n uint256 amount,\n bool isCheck\n ) public returns (uint256 useFromBalance) {\n if (!self.tokens.contains(token)) {\n self.tokens.add(token);\n }\n TokenBalance storage balance = self.tokenBalances[token];\n require(!isCheck || balance.amount >= balance.usedAmount + amount, \"use token failed with amount not enough\");\n TokenBalance memory preBalance = balance;\n if (balance.amount >= balance.usedAmount + amount) {\n balance.usedAmount += amount;\n useFromBalance = amount;\n } else if (balance.amount > balance.usedAmount) {\n useFromBalance = balance.amount - balance.usedAmount;\n balance.usedAmount += amount;\n } else {\n balance.usedAmount += amount;\n useFromBalance = 0;\n }\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, balance);\n }\n\n function unUseToken(Props storage self, address token, uint256 amount) public {\n require(self.tokens.contains(token), \"token not exists!\");\n require(self.tokenBalances[token].usedAmount >= amount, \"unuse overflow!\");\n TokenBalance memory preBalance = self.tokenBalances[token];\n self.tokenBalances[token].usedAmount -= amount;\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, self.tokenBalances[token]);\n }\n\n function repayLiability(Props storage self, address token) external {\n TokenBalance storage balance = self.tokenBalances[token];\n if (balance.liability > 0 && balance.amount > 0) {\n TokenBalance memory preBalance = balance;\n uint256 repayAmount = balance.amount >= balance.liability ? balance.liability : balance.amount;\n balance.amount -= repayAmount;\n balance.liability -= repayAmount;\n balance.usedAmount -= repayAmount;\n CommonData.load().subTokenLiability(token, repayAmount);\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, balance);\n }\n }\n\n function clearLiability(Props storage self, address token) external {\n TokenBalance storage balance = self.tokenBalances[token];\n TokenBalance memory preBalance = balance;\n CommonData.load().subTokenLiability(token, balance.liability);\n balance.usedAmount -= balance.liability;\n balance.liability = 0;\n emit AccountTokenUpdateEvent(self.owner, token, preBalance, balance);\n }\n\n function addPosition(Props storage self, bytes32 position) external {\n if (!self.positions.contains(position)) {\n self.positions.add(position);\n }\n }\n\n function delPosition(Props storage self, bytes32 position) external {\n self.positions.remove(position);\n }\n\n function checkExists(Props storage self) external view {\n if (self.owner == address(0)) {\n revert Errors.AccountNotExist();\n }\n }\n\n function getAllPosition(Props storage self) external view returns (bytes32[] memory) {\n return self.positions.values();\n }\n\n function hasPosition(Props storage self) external view returns (bool) {\n return self.positions.length() > 0;\n }\n\n function hasPosition(Props storage self, bytes32 key) external view returns (bool) {\n return self.positions.contains(key);\n }\n\n function getAllOrders(Props storage self) external view returns (uint256[] memory) {\n return self.orders.values();\n }\n\n function hasOrder(Props storage self) external view returns (bool) {\n return self.orders.length() > 0;\n }\n\n function hasOtherOrder(Props storage self, uint256 orderId) external view returns (bool) {\n uint256[] memory orderIds = self.orders.values();\n for (uint256 i; i < orderIds.length; i++) {\n if (orderIds[i] != orderId) {\n return true;\n }\n }\n return false;\n }\n\n function addOrder(Props storage self, uint256 orderId) external {\n if (!self.orders.contains(orderId)) {\n self.orders.add(orderId);\n }\n }\n\n function delOrder(Props storage self, uint256 orderId) external {\n self.orders.remove(orderId);\n }\n\n function getOrders(Props storage self) external view returns (uint256[] memory) {\n return self.orders.values();\n }\n\n function getTokens(Props storage self) public view returns (address[] memory) {\n return self.tokens.values();\n }\n\n function getSortedTokensByDiscount(Props storage self) external view returns (address[] memory) {\n address[] memory tokens = self.tokens.values();\n Config.Props storage config = Config.load();\n Config.TradeTokenConfig[] memory tokenConfigs = new Config.TradeTokenConfig[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n tokenConfigs[i] = config.getTradeTokenConfig(tokens[i]);\n }\n for (uint i = 1; i < tokenConfigs.length; i++) {\n Config.TradeTokenConfig memory temp = tokenConfigs[i];\n address tempToken = tokens[i];\n uint j = i;\n while ((j >= 1) && (temp.discount < tokenConfigs[j - 1].discount)) {\n tokenConfigs[j] = tokenConfigs[j - 1];\n tokens[j] = tokens[j - 1];\n j--;\n }\n tokenConfigs[j] = temp;\n tokens[j] = tempToken;\n }\n return tokens;\n }\n\n function getTokenBalance(Props storage self, address token) public view returns (TokenBalance memory) {\n return self.tokenBalances[token];\n }\n\n function getTokenAmount(Props storage self, address token) public view returns (uint256) {\n return self.tokenBalances[token].amount;\n }\n\n function getAvailableTokenAmount(Props storage self, address token) public view returns (uint256) {\n if (self.tokenBalances[token].amount > self.tokenBalances[token].usedAmount) {\n return self.tokenBalances[token].amount - self.tokenBalances[token].usedAmount;\n }\n return 0;\n }\n\n function hasLiability(Props storage self) external view returns (bool) {\n address[] memory tokens = self.tokens.values();\n for (uint256 i; i < tokens.length; i++) {\n if (self.tokenBalances[tokens[i]].liability > 0) {\n return true;\n }\n }\n return false;\n }\n}\n" + }, + "contracts/storage/ClaimRewards.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nlibrary ClaimRewards {\n bytes32 constant KEY = keccak256(abi.encode(\"xyz.elfi.storage.ClaimRewards\"));\n\n struct Props {\n mapping(uint256 => Request) requests;\n }\n\n struct Request {\n address account;\n address claimUsdToken;\n uint256 executionFee;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = KEY;\n assembly {\n self.slot := s\n }\n }\n\n function create(uint256 requestId) external view returns (Request storage) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function get(uint256 requestId) external view returns (Request memory) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function remove(uint256 requestId) external {\n Props storage self = load();\n delete self.requests[requestId];\n }\n}\n" + }, + "contracts/storage/CommonData.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nlibrary CommonData {\n bytes32 private constant COMMON_DATA = keccak256(abi.encode(\"link.profile.storage.CommonData\"));\n\n using EnumerableSet for EnumerableSet.AddressSet;\n\n struct Props {\n address stakeUsdToken;\n bytes32[] symbols;\n EnumerableSet.AddressSet stakeTokens;\n mapping(address => TokenData) tradeCollateralTokenDatas;\n mapping(address => uint256) stakeCollateralAmount;\n mapping(address => uint256) tokensTotalLiability;\n uint256 totalLossExecutionFee;\n }\n\n struct TokenData {\n uint256 totalCollateral;\n uint256 totalLiability;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = COMMON_DATA;\n assembly {\n self.slot := s\n }\n }\n\n function getStakeUsdToken() external view returns (address) {\n Props storage self = load();\n return self.stakeUsdToken;\n }\n\n function setStakeUsdToken(address stakeUsdToken) external {\n Props storage self = load();\n self.stakeUsdToken = stakeUsdToken;\n }\n\n function addSymbol(bytes32 code) external {\n Props storage self = load();\n self.symbols.push(code);\n }\n\n function addStakeTokens(address stakeToken) external {\n Props storage self = load();\n self.stakeTokens.add(stakeToken);\n }\n\n function isStakeTokenSupport(address stakeToken) external view returns (bool) {\n Props storage self = load();\n return self.stakeTokens.contains(stakeToken);\n }\n\n function getAllSymbols() external view returns (bytes32[] memory) {\n Props storage self = load();\n return self.symbols;\n }\n\n function getAllStakeTokens() external view returns (address[] memory) {\n Props storage self = load();\n return self.stakeTokens.values();\n }\n\n function addTradeTokenCollateral(Props storage self, address token, uint256 amount) external {\n self.tradeCollateralTokenDatas[token].totalCollateral += amount;\n }\n\n function subTradeTokenCollateral(Props storage self, address token, uint256 amount) external {\n require(\n self.tradeCollateralTokenDatas[token].totalCollateral >= amount,\n \"subTradeTokenCollateral less than amount\"\n );\n self.tradeCollateralTokenDatas[token].totalCollateral -= amount;\n }\n\n function addTradeTokenLiability(Props storage self, address token, uint256 amount) external {\n self.tradeCollateralTokenDatas[token].totalLiability += amount;\n }\n\n function subTradeTokenLiability(Props storage self, address token, uint256 amount) external {\n require(\n self.tradeCollateralTokenDatas[token].totalLiability >= amount,\n \"subTradeTokenLiability less than amount\"\n );\n self.tradeCollateralTokenDatas[token].totalLiability -= amount;\n }\n\n function getTradeTokenCollateral(Props storage self, address token) external view returns (uint256) {\n return self.tradeCollateralTokenDatas[token].totalCollateral;\n }\n\n function getTradeTokenLiability(Props storage self, address token) external view returns (uint256) {\n return self.tradeCollateralTokenDatas[token].totalLiability;\n }\n\n function addStakeCollateralAmount(Props storage self, address token, uint256 amount) external {\n self.stakeCollateralAmount[token] += amount;\n }\n\n function subStakeCollateralAmount(Props storage self, address token, uint256 amount) external {\n require(self.stakeCollateralAmount[token] >= amount, \"subStakeCollateralAmount less than amount\");\n self.stakeCollateralAmount[token] -= amount;\n }\n\n function getStakeCollateralAmount(Props storage self, address token) external view returns (uint256) {\n return self.stakeCollateralAmount[token];\n }\n\n function addTokenLiability(Props storage self, address token, uint256 addLiability) external {\n self.tokensTotalLiability[token] += addLiability;\n }\n\n function subTokenLiability(Props storage self, address token, uint256 subLiability) external {\n require(self.tokensTotalLiability[token] >= subLiability, \"subTokenLiability less than liability\");\n self.tokensTotalLiability[token] -= subLiability;\n }\n\n function getTokenLiability(Props storage self, address token) external view returns(uint256){\n return self.tokensTotalLiability[token];\n }\n\n function addLossExecutionFee(uint256 amount) external {\n Props storage self = load();\n self.totalLossExecutionFee += amount;\n }\n\n function subLossExecutionFee(uint256 amount) external {\n Props storage self = load();\n if (self.totalLossExecutionFee <= amount) {\n self.totalLossExecutionFee = 0;\n } else {\n self.totalLossExecutionFee -= amount;\n }\n }\n}\n" + }, + "contracts/storage/Config.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nlibrary Config {\n bytes32 private constant _CONFIG = keccak256(abi.encode(\"link.profit.storage.Config\"));\n\n using EnumerableSet for EnumerableSet.AddressSet;\n\n struct Props {\n CommonConfig commonConfig;\n ChainConfig chainConfig;\n StakeConfig stakeConfig;\n TradeConfig tradeConfig;\n UsdPoolConfig usdPoolConfig;\n mapping(address => LpPoolConfig) lpPoolConfigs;\n mapping(bytes32 => SymbolConfig) symbolConfigs;\n }\n\n struct AssetTokenConfig {\n address token;\n uint256 weight;\n }\n\n struct TradeConfig {\n EnumerableSet.AddressSet tokens;\n mapping(address => TradeTokenConfig) tokenConfigs;\n uint256 minOrderMarginUSD;\n uint256 availableCollateralRatio;\n uint256 crossLtvLimit;\n uint256 executeOrderMinBlockGap;\n uint256 executeOrderMaxBlockGap;\n uint256 executePositionMarginMinBlockGap;\n uint256 executePositionMarginMaxBlockGap;\n uint256 executeLeverageMinBlockGap;\n uint256 executeLeverageMaxBlockGap;\n uint256 maxMaintenanceMarginRate;\n uint256 fundingFeeBaseRate;\n uint256 tradingFeeStakingRewardsRatio;\n uint256 tradingFeePoolRewardsRatio;\n uint256 tradingFeeUsdPoolRewardsRatio;\n uint256 borrowingFeeStakingRewardsRatio;\n uint256 borrowingFeePoolRewardsRatio;\n uint256 autoReduceProfitFactor;\n uint256 autoReduceLiquidityFactor;\n uint256 swapSlipperTokenFactor;\n }\n\n struct StakeConfig {\n uint256 collateralProtectFactor;\n uint256 collateralFactor;\n uint256 minPrecisionMultiple;\n uint256 mintFeeStakingRewardsRatio;\n uint256 mintFeePoolRewardsRatio;\n uint256 redeemFeeStakingRewardsRatio;\n uint256 redeemFeePoolRewardsRatio;\n uint256 poolRewardsIntervalLimit;\n }\n\n struct CommonConfig {\n address uniswapRouter;\n }\n\n struct TradeTokenConfig {\n bool isSupportCollateral;\n uint8 precision;\n uint256 discount;\n uint256 collateralUserCap;\n uint256 collateralTotalCap;\n uint256 liabilityUserCap;\n uint256 liabilityTotalCap;\n uint256 interestRateFactor;\n uint256 liquidationFactor;\n address[] priorityCollaterals;\n }\n\n struct ChainConfig {\n address wrapperToken;\n uint256 mintGasFeeLimit;\n uint256 redeemGasFeeLimit;\n uint256 placeIncreaseOrderGasFeeLimit;\n uint256 placeDecreaseOrderGasFeeLimit;\n uint256 positionUpdateMarginGasFeeLimit;\n uint256 positionUpdateLeverageGasFeeLimit;\n uint256 claimRewardsGasFeeLimit;\n }\n\n struct StakeCollateralConfig {\n uint256 discount;\n uint256 collateralTotalCap;\n }\n\n struct LpPoolConfig {\n address[] assetTokens;\n EnumerableSet.AddressSet supportCollateralTokens;\n mapping(address => StakeCollateralConfig) collateralTokensConfigs;\n uint256 poolLiquidityLimit;\n uint256 mintFeeRate;\n uint256 redeemFeeRate;\n uint256 baseInterestRate;\n uint256 poolPnlRatioLimit;\n uint256 collateralStakingRatioLimit;\n uint256 unsettledBaseTokenRatioLimit;\n uint256 unsettledStableTokenRatioLimit;\n uint256 poolStableTokenRatioLimit;\n uint256 poolStableTokenLossLimit;\n }\n\n struct UsdPoolConfig {\n uint256 poolLiquidityLimit;\n uint256 mintFeeRate;\n uint256 redeemFeeRate;\n uint256 unsettledRatioLimit;\n mapping(address => uint256) baseInterestRates;\n mapping(address => uint256) stableTokenRatioLimits;\n }\n\n struct SymbolConfig {\n uint256 maxLeverage;\n uint256 tickSize;\n uint256 openFeeRate;\n uint256 closeFeeRate;\n uint256 maxLongOpenInterestCap;\n uint256 maxShortOpenInterestCap;\n uint256 longShortRatioLimit;\n uint256 longShortOiBottomLimit;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = _CONFIG;\n assembly {\n self.slot := s\n }\n }\n \n function getPoolConfig(Props storage self, address stakeToken) public view returns (LpPoolConfig storage config) {\n return self.lpPoolConfigs[stakeToken];\n }\n\n function getUsdPoolConfig(Props storage self) public view returns (UsdPoolConfig storage config) {\n return self.usdPoolConfig;\n }\n\n function getSymbolConfig(Props storage self, bytes32 code) public view returns (SymbolConfig storage config) {\n return self.symbolConfigs[code];\n }\n\n function getTradeTokenConfig(Props storage self, address token) external view returns (TradeTokenConfig storage) {\n return self.tradeConfig.tokenConfigs[token];\n }\n\n function isTradeTokenSupport(Props storage self, address token) external view returns (bool) {\n return self.tradeConfig.tokens.contains(token);\n }\n\n function isTradeCollateralSupport(Props storage self, address token) external view returns (bool) {\n return self.tradeConfig.tokenConfigs[token].isSupportCollateral;\n }\n\n function getTradeCollateralDiscount(Props storage self, address token) external view returns (uint256) {\n return self.tradeConfig.tokenConfigs[token].discount;\n }\n\n function getTradeCollateralLiquidationFactor(Props storage self, address token) external view returns (uint256) {\n return self.tradeConfig.tokenConfigs[token].liquidationFactor;\n }\n\n function getTradeMaxMaintenanceMarginRate() external view returns (uint256) {\n Props storage self = load();\n return self.tradeConfig.maxMaintenanceMarginRate;\n }\n\n function getTradeConfig(Props storage self) external view returns (TradeConfig storage) {\n return self.tradeConfig;\n }\n\n function getStakeConfig(Props storage self) external view returns (StakeConfig storage) {\n return self.stakeConfig;\n }\n\n function addTradeToken(Props storage self, address token, TradeTokenConfig memory tokenConfig) external {\n if (!self.tradeConfig.tokens.contains(token)) {\n self.tradeConfig.tokens.add(token);\n }\n self.tradeConfig.tokenConfigs[token] = tokenConfig;\n }\n\n function getWrapperToken(Props storage self) external view returns(address) {\n return self.chainConfig.wrapperToken; \n }\n\n function getWrapperToken() external view returns(address) {\n Props storage self = load();\n return self.chainConfig.wrapperToken; \n }\n\n function getChainConfig() external view returns (ChainConfig memory) {\n Props storage self = load();\n return self.chainConfig;\n }\n\n function getUniswapRouter() external view returns(address) {\n Props storage self = load();\n return self.commonConfig.uniswapRouter;\n }\n}\n" + }, + "contracts/storage/FeeRewards.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nlibrary FeeRewards {\n using EnumerableMap for EnumerableMap.AddressToUintMap;\n using EnumerableSet for EnumerableSet.AddressSet;\n using SafeMath for uint256;\n\n bytes32 private constant FEE_REWARDS = keccak256(\"xyz.elfi.storage.FeeRewards\");\n bytes32 private constant FEE_AMOUNT_PREFIX = keccak256(abi.encode(\"FEE_AMOUNT_PREFIX\"));\n\n function generateFeeAmountKey(address market, address token) internal pure returns (bytes32) {\n return keccak256(abi.encode(FEE_AMOUNT_PREFIX, market, token));\n }\n\n struct Props {\n mapping(bytes32 => MarketRewards) marketTradingRewards;\n mapping(address => MarketRewards) poolRewards;\n StakingRewards stakingRewards;\n StakingRewards daoRewards;\n }\n\n struct MarketRewards {\n EnumerableSet.AddressSet tokens;\n mapping(address => uint256) feeAmount;\n mapping(address => uint256) unsettledFeeAmount;\n EnumerableSet.AddressSet collateralTokens;\n mapping(address => uint256) collateralFeeAmount;\n uint256 cumulativeRewardsPerStakeToken;\n uint256[] lastRewardsPerStakeTokenDeltas;\n }\n\n struct StakingRewards {\n EnumerableSet.AddressSet tokens;\n mapping(bytes32 => uint256) feeAmount;\n mapping(bytes32 => uint256) unsettledFeeAmount;\n EnumerableSet.AddressSet collateralTokens;\n mapping(bytes32 => uint256) collateralFeeAmount;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = FEE_REWARDS;\n assembly {\n self.slot := s\n }\n }\n\n function loadPoolRewards(address stakeToken) public view returns (MarketRewards storage) {\n return load().poolRewards[stakeToken];\n }\n\n function loadMarketTradingRewards(bytes32 symbol) public view returns (MarketRewards storage) {\n return load().marketTradingRewards[symbol];\n }\n\n function loadStakingRewards() public view returns (StakingRewards storage) {\n return load().stakingRewards;\n }\n\n function loadDaoRewards() public view returns (StakingRewards storage) {\n return load().daoRewards;\n }\n\n function addFeeAmount(MarketRewards storage self, address token, uint256 fee) external {\n if (!self.tokens.contains(token)) {\n self.tokens.add(token);\n }\n self.feeAmount[token] = self.feeAmount[token] + fee;\n }\n\n function subFeeAmount(MarketRewards storage self, address token, uint256 fee) external {\n self.feeAmount[token] = self.feeAmount[token] - fee;\n }\n\n function setFeeAmountZero(MarketRewards storage self, address token) external {\n self.feeAmount[token] = 0;\n }\n\n function addUnsettleFeeAmount(MarketRewards storage self, address token, uint256 fee) external {\n if (!self.tokens.contains(token)) {\n self.tokens.add(token);\n }\n self.unsettledFeeAmount[token] = self.unsettledFeeAmount[token] + fee;\n }\n\n function subUnsettleFeeAmount(MarketRewards storage self, address token, uint256 fee) external {\n self.unsettledFeeAmount[token] = self.unsettledFeeAmount[token] - fee;\n }\n\n function addCollateralFeeAmount(MarketRewards storage self, address token, uint256 fee) external {\n if (!self.collateralTokens.contains(token)) {\n self.collateralTokens.add(token);\n }\n self.collateralFeeAmount[token] = self.collateralFeeAmount[token] + fee;\n }\n\n function subCollateralFeeAmount(MarketRewards storage self, address token, uint256 fee) external {\n self.collateralFeeAmount[token] = self.collateralFeeAmount[token] - fee;\n }\n\n function getFeeTokens(MarketRewards storage self) external view returns (address[] memory) {\n return self.tokens.values();\n }\n\n function getCollateralFeeTokens(MarketRewards storage self) external view returns (address[] memory) {\n return self.collateralTokens.values();\n }\n\n function getFeeAmount(MarketRewards storage self, address token) external view returns (uint256) {\n return self.feeAmount[token];\n }\n\n function getUnsettleFeeAmount(MarketRewards storage self, address token) external view returns (uint256) {\n return self.unsettledFeeAmount[token];\n }\n\n function getCollateralFeeAmount(MarketRewards storage self, address token) external view returns (uint256) {\n return self.collateralFeeAmount[token];\n }\n\n function getCumulativeRewardsPerStakeToken(MarketRewards storage self) external view returns (uint256) {\n return self.cumulativeRewardsPerStakeToken;\n }\n\n function addLastRewardsPerStakeTokenDelta(\n MarketRewards storage self,\n uint256 delta,\n uint256 maxIntervals\n ) external {\n if (self.lastRewardsPerStakeTokenDeltas.length >= maxIntervals) {\n delete self.lastRewardsPerStakeTokenDeltas[0];\n }\n self.lastRewardsPerStakeTokenDeltas.push(delta);\n }\n\n function getPoolRewardsPerStakeTokenDeltaLimit(\n MarketRewards storage self\n ) external view returns (uint256 deltaLimit) {\n for (uint256 i; i < self.lastRewardsPerStakeTokenDeltas.length; i++) {\n deltaLimit += self.lastRewardsPerStakeTokenDeltas[i];\n }\n }\n\n function addFeeAmount(StakingRewards storage self, address market, address token, uint256 fee) external {\n if (!self.tokens.contains(token)) {\n self.tokens.add(token);\n }\n bytes32 key = generateFeeAmountKey(market, token);\n self.feeAmount[key] = self.feeAmount[key] + fee;\n }\n\n function addUnsettleFeeAmount(StakingRewards storage self, address market, address token, uint256 fee) external {\n if (!self.tokens.contains(token)) {\n self.tokens.add(token);\n }\n bytes32 key = generateFeeAmountKey(market, token);\n self.unsettledFeeAmount[key] = self.unsettledFeeAmount[key] + fee;\n }\n\n function addCollateralFeeAmount(StakingRewards storage self, address market, address token, uint256 fee) external {\n if (!self.collateralTokens.contains(token)) {\n self.collateralTokens.add(token);\n }\n bytes32 key = generateFeeAmountKey(market, token);\n self.collateralFeeAmount[key] = self.collateralFeeAmount[key] + fee;\n }\n\n function getFeeAmount(StakingRewards storage self, address market, address token) external view returns (uint256) {\n bytes32 key = generateFeeAmountKey(market, token);\n return self.feeAmount[key];\n }\n\n function getUnsettleFeeAmount(\n StakingRewards storage self,\n address market,\n address token\n ) external view returns (uint256) {\n bytes32 key = generateFeeAmountKey(market, token);\n return self.unsettledFeeAmount[key];\n }\n\n function getCollateralFeeAmount(\n StakingRewards storage self,\n address market,\n address token\n ) external view returns (uint256) {\n bytes32 key = generateFeeAmountKey(market, token);\n return self.collateralFeeAmount[key];\n }\n}\n" + }, + "contracts/storage/InsuranceFund.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nlibrary InsuranceFund {\n using EnumerableMap for EnumerableMap.AddressToUintMap;\n using SafeMath for uint256;\n\n struct Props {\n EnumerableMap.AddressToUintMap funds;\n }\n\n function load(address stakeToken) public pure returns (Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profit.storage.InsuranceFund\", stakeToken));\n assembly {\n self.slot := s\n }\n }\n\n function addFunds(address stakeToken, address token, uint256 amount) public {\n InsuranceFund.Props storage self = load(stakeToken);\n (bool exists, uint256 preAmount) = self.funds.tryGet(token);\n if (exists) {\n self.funds.set(token, preAmount + amount);\n } else {\n self.funds.set(token, amount);\n }\n }\n\n function getFundsTokens(InsuranceFund.Props storage self) external view returns (address[] memory) {\n return self.funds.keys();\n }\n\n function getTokenFee(InsuranceFund.Props storage self, address token) external view returns (uint256) {\n (bool exists, uint256 preAmount) = self.funds.tryGet(token);\n return exists ? preAmount : 0;\n }\n}\n" + }, + "contracts/storage/LiabilityClean.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nlibrary LiabilityClean {\n using EnumerableSet for EnumerableSet.UintSet;\n\n struct Props {\n EnumerableSet.UintSet cleanIds;\n mapping(uint256 => LiabilityCleanInfo) cleanInfos;\n }\n\n struct LiabilityCleanInfo {\n address account;\n uint256 liquidationTime;\n address[] liabilityTokens;\n uint256[] liabilities;\n address[] collaterals;\n uint256[] collateralsAmount;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profit.storage.LiabilityClean\"));\n assembly {\n self.slot := s\n }\n }\n\n function newClean(uint256 cleanId) external returns (LiabilityCleanInfo storage info) {\n Props storage self = load();\n self.cleanIds.add(cleanId);\n return self.cleanInfos[cleanId];\n }\n\n function addClean(uint256 cleanId, LiabilityCleanInfo memory info) external {\n Props storage self = load();\n self.cleanIds.add(cleanId);\n self.cleanInfos[cleanId] = info;\n }\n\n function removeClean(uint256 cleanId) external {\n Props storage self = load();\n self.cleanIds.remove(cleanId);\n delete self.cleanInfos[cleanId];\n }\n\n function getAllCleanInfo() external view returns(LiabilityCleanInfo[] memory) {\n Props storage self = load();\n uint256[] memory ids = self.cleanIds.values();\n LiabilityCleanInfo[] memory cleanInfos = new LiabilityCleanInfo[](ids.length);\n for (uint256 i; i < ids.length; i++) {\n cleanInfos[i] = self.cleanInfos[ids[i]];\n }\n return cleanInfos;\n }\n}\n" + }, + "contracts/storage/LibDiamond.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\nimport { IDiamond } from \"../interfaces/IDiamond.sol\";\nimport { IDiamondCut } from \"../interfaces/IDiamondCut.sol\";\n\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\n// The loupe functions are required by the EIP2535 Diamonds standard\n\nerror NoSelectorsGivenToAdd();\nerror NotContractOwner(address _user, address _contractOwner);\nerror NoSelectorsProvidedForFacetForCut(address _facetAddress);\nerror CannotAddSelectorsToZeroAddress(bytes4[] _selectors);\nerror NoBytecodeAtAddress(address _contractAddress, string _message);\nerror IncorrectFacetCutAction(uint8 _action);\nerror CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);\nerror CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);\nerror CannotReplaceImmutableFunction(bytes4 _selector);\nerror CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);\nerror CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);\nerror RemoveFacetAddressMustBeZeroAddress(address _facetAddress);\nerror CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);\nerror CannotRemoveImmutableFunction(bytes4 _selector);\nerror InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);\n\nlibrary LibDiamond {\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\"diamond.standard.diamond.storage\");\n\n struct FacetAddressAndSelectorPosition {\n address facetAddress;\n uint16 selectorPosition;\n }\n\n struct DiamondStorage {\n // function selector => facet address and selector position in selectors array\n mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;\n bytes4[] selectors;\n mapping(bytes4 => bool) supportedInterfaces;\n address contractOwner;\n }\n\n function diamondStorage() internal pure returns (DiamondStorage storage ds) {\n bytes32 position = DIAMOND_STORAGE_POSITION;\n assembly {\n ds.slot := position\n }\n }\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n function setContractOwner(address _newOwner) internal {\n DiamondStorage storage ds = diamondStorage();\n address previousOwner = ds.contractOwner;\n ds.contractOwner = _newOwner;\n emit OwnershipTransferred(previousOwner, _newOwner);\n }\n\n function contractOwner() internal view returns (address contractOwner_) {\n contractOwner_ = diamondStorage().contractOwner;\n }\n\n function enforceIsContractOwner() internal view {\n if (msg.sender != diamondStorage().contractOwner) {\n revert NotContractOwner(msg.sender, diamondStorage().contractOwner);\n }\n }\n\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);\n\n // Internal function version of diamondCut\n function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {\n for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\n bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors;\n address facetAddress = _diamondCut[facetIndex].facetAddress;\n if (functionSelectors.length == 0) {\n revert NoSelectorsProvidedForFacetForCut(facetAddress);\n }\n IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;\n if (action == IDiamond.FacetCutAction.Add) {\n addFunctions(facetAddress, functionSelectors);\n } else if (action == IDiamond.FacetCutAction.Replace) {\n replaceFunctions(facetAddress, functionSelectors);\n } else if (action == IDiamond.FacetCutAction.Remove) {\n removeFunctions(facetAddress, functionSelectors);\n } else {\n revert IncorrectFacetCutAction(uint8(action));\n }\n }\n emit DiamondCut(_diamondCut, _init, _calldata);\n initializeDiamondCut(_init, _calldata);\n }\n\n function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\n if (_facetAddress == address(0)) {\n revert CannotAddSelectorsToZeroAddress(_functionSelectors);\n }\n DiamondStorage storage ds = diamondStorage();\n uint16 selectorCount = uint16(ds.selectors.length);\n enforceHasContractCode(_facetAddress, \"LibDiamondCut: Add facet has no code\");\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\n bytes4 selector = _functionSelectors[selectorIndex];\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\n if (oldFacetAddress != address(0)) {\n revert CannotAddFunctionToDiamondThatAlreadyExists(selector);\n }\n ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(\n _facetAddress,\n selectorCount\n );\n ds.selectors.push(selector);\n selectorCount++;\n }\n }\n\n function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\n DiamondStorage storage ds = diamondStorage();\n if (_facetAddress == address(0)) {\n revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);\n }\n enforceHasContractCode(_facetAddress, \"LibDiamondCut: Replace facet has no code\");\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\n bytes4 selector = _functionSelectors[selectorIndex];\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\n // can't replace immutable functions -- functions defined directly in the diamond in this case\n if (oldFacetAddress == address(this)) {\n revert CannotReplaceImmutableFunction(selector);\n }\n if (oldFacetAddress == _facetAddress) {\n revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);\n }\n if (oldFacetAddress == address(0)) {\n revert CannotReplaceFunctionThatDoesNotExists(selector);\n }\n // replace old facet address\n ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress;\n }\n }\n\n function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\n DiamondStorage storage ds = diamondStorage();\n uint256 selectorCount = ds.selectors.length;\n if (_facetAddress != address(0)) {\n revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);\n }\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\n bytes4 selector = _functionSelectors[selectorIndex];\n FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds\n .facetAddressAndSelectorPosition[selector];\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {\n revert CannotRemoveFunctionThatDoesNotExist(selector);\n }\n\n // can't remove immutable functions -- functions defined directly in the diamond\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {\n revert CannotRemoveImmutableFunction(selector);\n }\n // replace selector with last selector\n selectorCount--;\n if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {\n bytes4 lastSelector = ds.selectors[selectorCount];\n ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;\n ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition\n .selectorPosition;\n }\n // delete last selector\n ds.selectors.pop();\n delete ds.facetAddressAndSelectorPosition[selector];\n }\n }\n\n function initializeDiamondCut(address _init, bytes memory _calldata) internal {\n if (_init == address(0)) {\n return;\n }\n enforceHasContractCode(_init, \"LibDiamondCut: _init address has no code\");\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\n if (!success) {\n if (error.length > 0) {\n // bubble up error\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(error)\n revert(add(32, error), returndata_size)\n }\n } else {\n revert InitializationFunctionReverted(_init, _calldata);\n }\n }\n }\n\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\n uint256 contractSize;\n assembly {\n contractSize := extcodesize(_contract)\n }\n if (contractSize == 0) {\n revert NoBytecodeAtAddress(_contract, _errorMessage);\n }\n }\n}\n" + }, + "contracts/storage/LpPool.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/ChainUtils.sol\";\nimport \"../utils/Errors.sol\";\nimport \"./Config.sol\";\n\nlibrary LpPool {\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableMap for EnumerableMap.AddressToUintMap;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SafeMath for uint256;\n using Config for Config.Props;\n\n struct Props {\n address stakeToken;\n string stakeTokenName;\n address baseToken;\n bytes32 symbol;\n TokenBalance baseTokenBalance;\n EnumerableSet.AddressSet stableTokens;\n mapping(address => TokenBalance) stableTokenBalances;\n mapping(address => FeeRewards) tradingFeeRewards;\n BorrowingFee borrowingFee;\n uint256 apr;\n }\n\n struct TokenBalance {\n uint256 amount;\n uint256 liability;\n uint256 holdAmount;\n int256 unsettledAmount;\n uint256 lossAmount;\n EnumerableMap.AddressToUintMap collateralTokenAmounts;\n }\n\n struct FeeRewards {\n uint256 amount;\n uint256 unsettledAmount;\n }\n\n struct BorrowingFee {\n // uint256 baseInterestRate;\n uint256 totalBorrowingFee;\n uint256 totalRealizedBorrowingFee;\n uint256 cumulativeBorrowingFeePerToken;\n uint256 lastUpdateTime;\n }\n\n struct PoolTokenUpdateEventCache {\n address stakeToken;\n address token;\n uint256 preAmount;\n uint256 preLiability;\n uint256 preHoldAmount;\n int256 preUnsettledAmount;\n uint256 preLossAmount;\n uint256 amount;\n uint256 liability;\n uint256 holdAmount;\n int256 unsettledAmount;\n uint256 lossAmount;\n uint256 updateBlock;\n }\n\n event PoolTokenUpdateEvent(\n address stakeToken,\n address token,\n uint256 preAmount,\n uint256 preLiability,\n uint256 preHoldAmount,\n int256 preUnsettledAmount,\n uint256 preLossAmount,\n uint256 amount,\n uint256 liability,\n uint256 holdAmount,\n int256 unsettledAmount,\n uint256 lossAmount,\n uint256 updateBlock\n );\n\n event PoolCollateralTokenUpdateEvent(\n address stakeToken,\n address collateral,\n uint256 preAmount,\n uint256 amount,\n uint256 updateBlock\n );\n\n function load(address stakeToken) public pure returns (Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profile.storage.LpPool\", stakeToken));\n\n assembly {\n self.slot := s\n }\n }\n\n function getPoolConfig(address stakeToken) public view returns (Config.LpPoolConfig storage) {\n return Config.load().getPoolConfig(stakeToken);\n }\n\n function addBaseToken(Props storage self, uint256 amount) external {\n addBaseToken(self, amount, true);\n }\n\n function addBaseToken(Props storage self, uint256 amount, bool needEmitEvent) public {\n if (needEmitEvent) {\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(\n self.stakeToken,\n self.baseToken,\n self.baseTokenBalance\n );\n self.baseTokenBalance.amount += amount;\n cache.amount = self.baseTokenBalance.amount;\n _emitPoolUpdateEvent(cache);\n } else {\n self.baseTokenBalance.amount += amount;\n }\n }\n\n function addCollateralBaseToken(\n Props storage self,\n uint256 amount,\n address collateral,\n uint256 collateralAmount\n ) external {\n TokenBalance storage balance = self.baseTokenBalance;\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(self.stakeToken, self.baseToken, balance);\n balance.amount += amount;\n balance.liability += amount;\n cache.amount = balance.amount;\n cache.liability = balance.liability;\n\n (bool exists, uint256 tokenAmount) = balance.collateralTokenAmounts.tryGet(collateral);\n if (exists) {\n balance.collateralTokenAmounts.set(collateral, tokenAmount + collateralAmount);\n } else {\n balance.collateralTokenAmounts.set(collateral, collateralAmount);\n }\n _emitPoolUpdateEvent(cache);\n emit PoolCollateralTokenUpdateEvent(\n self.stakeToken,\n collateral,\n tokenAmount,\n tokenAmount + collateralAmount,\n ChainUtils.currentBlock()\n );\n }\n\n function subBaseToken(Props storage self, uint256 amount) external {\n subBaseToken(self, amount, true);\n }\n\n function subBaseToken(Props storage self, uint256 amount, bool emitEvent) public {\n require(self.baseTokenBalance.amount >= amount, \"base token amount less than sub amount!\");\n if (emitEvent) {\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(\n self.stakeToken,\n self.baseToken,\n self.baseTokenBalance\n );\n self.baseTokenBalance.amount -= amount;\n cache.amount = self.baseTokenBalance.amount;\n _emitPoolUpdateEvent(cache);\n } else {\n self.baseTokenBalance.amount -= amount;\n }\n }\n\n function subCollateralBaseToken(\n Props storage self,\n uint256 amount,\n address collateral,\n uint256 collateralAmount\n ) external {\n require(\n self.baseTokenBalance.amount >= amount && self.baseTokenBalance.liability >= amount,\n \"sub failed with balance not enough\"\n );\n\n TokenBalance storage balance = self.baseTokenBalance;\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(self.stakeToken, self.baseToken, balance);\n balance.amount -= amount;\n balance.liability -= amount;\n cache.amount = balance.amount;\n cache.liability = balance.liability;\n uint256 tokenAmount = balance.collateralTokenAmounts.get(collateral);\n if (tokenAmount == collateralAmount) {\n balance.collateralTokenAmounts.remove(collateral);\n } else {\n balance.collateralTokenAmounts.set(collateral, tokenAmount - collateralAmount);\n }\n\n _emitPoolUpdateEvent(cache);\n emit PoolCollateralTokenUpdateEvent(\n self.stakeToken,\n collateral,\n tokenAmount,\n tokenAmount - collateralAmount,\n ChainUtils.currentBlock()\n );\n }\n\n function holdBaseToken(Props storage self, uint256 amount) external {\n require(\n isHoldAmountAllowed(self.baseTokenBalance, getPoolLiquidityLimit(self), amount),\n \"hold failed with balance not enough\"\n );\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(\n self.stakeToken,\n self.baseToken,\n self.baseTokenBalance\n );\n self.baseTokenBalance.holdAmount += amount;\n cache.holdAmount = self.baseTokenBalance.holdAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function unHoldBaseToken(Props storage self, uint256 amount) external {\n require(self.baseTokenBalance.holdAmount >= amount, \"sub hold bigger than hold\");\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(\n self.stakeToken,\n self.baseToken,\n self.baseTokenBalance\n );\n self.baseTokenBalance.holdAmount -= amount;\n cache.holdAmount = self.baseTokenBalance.holdAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function addUnsettleBaseToken(Props storage self, int256 amount) external {\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(\n self.stakeToken,\n self.baseToken,\n self.baseTokenBalance\n );\n self.baseTokenBalance.unsettledAmount += amount;\n cache.unsettledAmount = self.baseTokenBalance.unsettledAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function settleBaseToken(Props storage self, uint256 amount) external {\n int256 amountInt = amount.toInt256();\n require(self.baseTokenBalance.unsettledAmount >= amountInt, \"settle base token overflow!\");\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(\n self.stakeToken,\n self.baseToken,\n self.baseTokenBalance\n );\n self.baseTokenBalance.unsettledAmount -= amountInt;\n self.baseTokenBalance.amount += amount;\n cache.unsettledAmount = self.baseTokenBalance.unsettledAmount;\n cache.amount = self.baseTokenBalance.amount;\n _emitPoolUpdateEvent(cache);\n }\n\n function addStableToken(Props storage self, address stableToken, uint256 amount) external {\n if (self.stableTokens.contains(stableToken)) {\n self.stableTokenBalances[stableToken].amount += amount;\n } else {\n self.stableTokens.add(stableToken);\n self.stableTokenBalances[stableToken].amount = amount;\n }\n }\n\n function subStableToken(Props storage self, address stableToken, uint256 amount) external {\n self.stableTokenBalances[stableToken].amount -= amount;\n if (self.stableTokenBalances[stableToken].amount == 0) {\n self.stableTokens.remove(stableToken);\n delete self.stableTokenBalances[stableToken];\n }\n }\n\n function holdStableToken(Props storage self, address stableToken, uint256 amount) external {\n require(\n isHoldAmountAllowed(self.stableTokenBalances[stableToken], getPoolLiquidityLimit(self), amount),\n \"hold failed with balance not enough\"\n );\n self.stableTokenBalances[stableToken].holdAmount += amount;\n }\n\n function unHoldStableToken(Props storage self, address stableToken, uint256 amount) external {\n require(self.stableTokenBalances[stableToken].holdAmount < amount, \"sub hold bigger than hold\");\n self.stableTokenBalances[stableToken].holdAmount -= amount;\n }\n\n function addUnsettleStableToken(Props storage self, address stableToken, int256 amount) external {\n if (!self.stableTokens.contains(stableToken)) {\n self.stableTokens.add(stableToken);\n }\n self.stableTokenBalances[stableToken].unsettledAmount += amount;\n }\n\n function settleStableToken(Props storage self, address stableToken, uint256 amount) external {\n if (!self.stableTokens.contains(stableToken)) {\n self.stableTokens.add(stableToken);\n }\n int256 amountInt = amount.toInt256();\n TokenBalance storage balance = self.stableTokenBalances[stableToken];\n require(balance.unsettledAmount >= amountInt, \"settle stable token overflow!\");\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(self.stakeToken, stableToken, balance);\n balance.unsettledAmount -= amountInt;\n balance.amount += amount;\n cache.unsettledAmount = balance.unsettledAmount;\n cache.amount = balance.amount;\n \n _emitPoolUpdateEvent(cache);\n }\n\n function addLossStableToken(Props storage self, address stableToken, uint256 amount) external {\n if (!self.stableTokens.contains(stableToken)) {\n self.stableTokens.add(stableToken);\n }\n TokenBalance storage balance = self.stableTokenBalances[stableToken];\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(self.stakeToken, stableToken, balance);\n balance.lossAmount += amount;\n cache.lossAmount = balance.lossAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function subLossStableToken(Props storage self, address stableToken, uint256 amount) external {\n if (!self.stableTokens.contains(stableToken)) {\n self.stableTokens.add(stableToken);\n }\n TokenBalance storage balance = self.stableTokenBalances[stableToken];\n require(balance.lossAmount >= amount, \"sub loss stable token overflow!\");\n PoolTokenUpdateEventCache memory cache = _convertBalanceToCache(self.stakeToken, stableToken, balance);\n balance.lossAmount -= amount;\n cache.lossAmount = balance.lossAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function getStableTokens(Props storage self) external view returns (address[] memory) {\n return self.stableTokens.values();\n }\n\n function getStableTokenBalance(\n Props storage self,\n address stableToken\n ) external view returns (TokenBalance storage) {\n return self.stableTokenBalances[stableToken];\n }\n\n function getSupportCollateralTokens(Props storage self) external view returns (address[] memory) {\n return getPoolConfig(self.stakeToken).supportCollateralTokens.values();\n }\n\n function getPoolLiquidityLimit(Props storage self) public view returns (uint256) {\n return getPoolConfig(self.stakeToken).poolLiquidityLimit;\n }\n\n function addStakeCollateralToken(\n Props storage self,\n address token,\n Config.StakeCollateralConfig memory collateralConfig\n ) external {\n getPoolConfig(self.stakeToken).supportCollateralTokens.add(token);\n getPoolConfig(self.stakeToken).collateralTokensConfigs[token] = collateralConfig;\n }\n\n function isStakeCollateralSupport(Props storage self, address collateral) external view returns (bool) {\n return getPoolConfig(self.stakeToken).supportCollateralTokens.contains(collateral);\n }\n\n function getStakeCollateralConfig(\n Props storage self,\n address collateral\n ) external view returns (Config.StakeCollateralConfig memory) {\n return getPoolConfig(self.stakeToken).collateralTokensConfigs[collateral];\n }\n\n function getCollateralTokenAmounts(\n EnumerableMap.AddressToUintMap storage collateralTokenAmounts\n ) external view returns (address[] memory tokens, uint256[] memory amounts) {\n tokens = collateralTokenAmounts.keys();\n amounts = new uint256[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n amounts[i] = collateralTokenAmounts.get(tokens[i]);\n }\n }\n\n function getCollateralTokenAmount(Props storage self, address token) external view returns (uint256) {\n (bool exists, uint256 amount) = self.baseTokenBalance.collateralTokenAmounts.tryGet(token);\n return exists ? amount : 0;\n }\n\n function isSubAmountAllowed(Props storage self, address token, uint256 amount) internal view returns (bool) {\n TokenBalance storage balance = token == self.baseToken\n ? self.baseTokenBalance\n : self.stableTokenBalances[token];\n if (balance.amount < amount) {\n return false;\n }\n uint256 poolLiquidityLimit = getPoolLiquidityLimit(self);\n if (poolLiquidityLimit == 0) {\n return\n balance.amount.toInt256() + balance.unsettledAmount - balance.holdAmount.toInt256() >=\n amount.toInt256();\n } else {\n return\n CalUtils.mulRate(\n balance.amount.toInt256() - amount.toInt256() + balance.unsettledAmount,\n poolLiquidityLimit.toInt256()\n ) >= balance.holdAmount.toInt256();\n }\n }\n\n function isHoldAmountAllowed(\n TokenBalance storage balance,\n uint256 poolLiquidityLimit,\n uint256 amount\n ) public view returns (bool) {\n if (poolLiquidityLimit == 0) {\n return\n balance.amount.toInt256() + balance.unsettledAmount - balance.holdAmount.toInt256() >=\n amount.toInt256();\n } else {\n return\n CalUtils.mulRate(balance.amount.toInt256() + balance.unsettledAmount, poolLiquidityLimit.toInt256()) -\n balance.holdAmount.toInt256() >=\n amount.toInt256();\n }\n }\n\n function checkExists(Props storage self) external view {\n if (self.baseToken == address(0)) {\n revert Errors.PoolNotExists();\n }\n }\n\n function _convertBalanceToCache(\n address stakeToken,\n address token,\n TokenBalance storage balance\n ) internal view returns (PoolTokenUpdateEventCache memory cache) {\n cache.stakeToken = stakeToken;\n cache.token = token;\n cache.preAmount = balance.amount;\n cache.preLiability = balance.liability;\n cache.preHoldAmount = balance.holdAmount;\n cache.preUnsettledAmount = balance.unsettledAmount;\n cache.preLossAmount = balance.lossAmount;\n cache.amount = balance.amount;\n cache.liability = balance.liability;\n cache.holdAmount = balance.holdAmount;\n cache.unsettledAmount = balance.unsettledAmount;\n cache.lossAmount = balance.lossAmount;\n cache.updateBlock = ChainUtils.currentBlock();\n }\n\n function _emitPoolUpdateEvent(PoolTokenUpdateEventCache memory cache) internal {\n emit PoolTokenUpdateEvent(\n cache.stakeToken,\n cache.token,\n cache.preAmount,\n cache.preLiability,\n cache.preHoldAmount,\n cache.preUnsettledAmount,\n cache.preLossAmount,\n cache.amount,\n cache.liability,\n cache.holdAmount,\n cache.unsettledAmount,\n cache.lossAmount,\n cache.updateBlock\n );\n }\n}\n" + }, + "contracts/storage/Market.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\n\nlibrary Market {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n struct Props {\n bytes32 symbol;\n address stakeToken;\n MarketPosition longPosition;\n EnumerableSet.AddressSet shortPositionTokens;\n mapping(address => MarketPosition) shortPositionMap;\n FundingFee fundingFee;\n }\n\n struct MarketPosition {\n uint256 openInterest;\n uint256 entryPrice;\n }\n\n struct FundingFee {\n int256 longFundingFeePerQty;\n int256 shortFundingFeePerQty;\n int256 totalLongFundingFee;\n int256 totalShortFundingFee;\n uint256 lastUpdateTime;\n }\n\n function load(bytes32 symbol) public pure returns (Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profile.storage.Market\", symbol));\n\n assembly {\n self.slot := s\n }\n }\n\n function addShortToken(Props storage self, address token) external {\n if (!self.shortPositionTokens.contains(token)) {\n self.shortPositionTokens.add(token);\n }\n }\n\n function getShortPositionTokens(Props storage self) external view returns (address[] memory) {\n return self.shortPositionTokens.values();\n }\n\n function getShortPosition(Props storage self, address token) external view returns (MarketPosition memory) {\n return self.shortPositionMap[token];\n }\n\n function getAllShortPositions(Props storage self) external view returns (MarketPosition[] memory) {\n address[] memory tokens = self.shortPositionTokens.values();\n MarketPosition[] memory shortPositions = new MarketPosition[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n shortPositions[i] = self.shortPositionMap[tokens[i]]; \n }\n return shortPositions;\n }\n\n function getLongOpenInterest(Props storage self) external view returns (uint256) {\n return self.longPosition.openInterest;\n }\n\n function getAllShortOpenInterest(Props storage self) external view returns (uint256) {\n address[] memory tokens = self.shortPositionTokens.values();\n uint256 sum = 0;\n for (uint256 i; i < tokens.length; i++) {\n sum += self.shortPositionMap[tokens[i]].openInterest;\n }\n return sum;\n }\n}\n" + }, + "contracts/storage/Mint.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nlibrary Mint {\n bytes32 constant MINT_KEY = keccak256(abi.encode(\"link.profile.storage.Mint\"));\n\n struct Props {\n mapping(uint256 => Request) requests;\n }\n\n struct Request {\n address account;\n address receiver;\n address stakeToken;\n address requestToken;\n uint256 requestTokenAmount;\n uint256 walletRequestTokenAmount;\n uint256 minStakeAmount;\n uint256 executionFee;\n bool isCollateral;\n bool isExecutionFeeFromLpVault;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = MINT_KEY;\n assembly {\n self.slot := s\n }\n }\n\n function create(uint256 requestId) external view returns (Request storage) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function get(uint256 requestId) external view returns (Request memory) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function remove(uint256 requestId) external {\n Props storage self = load();\n delete self.requests[requestId];\n }\n}\n" + }, + "contracts/storage/OracleFeed.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nlibrary OracleFeed {\n\n // enum OracleFrom {\n // NONE, CHAINLINK\n // }\n\n struct Props {\n // OracleFrom from;\n mapping(address => address) feedUsdAddresses;\n }\n\n function load() public pure returns(Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profit.storage.OracleFeed\"));\n assembly {\n self.slot := s\n }\n }\n\n function create(address[] memory tokens, address[] memory usdFeeds) external returns(Props storage feed) {\n feed = load();\n for (uint256 i; i < tokens.length; i++) {\n feed.feedUsdAddresses[tokens[i]] = usdFeeds[i];\n }\n }\n\n function getFeedUsdAddress(address token) external view returns (address){\n Props storage feedProps = load();\n return feedProps.feedUsdAddresses[token];\n }\n\n}\n" + }, + "contracts/storage/OraclePrice.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nlibrary OraclePrice {\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.Bytes32Set;\n\n bytes32 private constant _ORACLE_PRICE = keccak256(abi.encode(\"link.profit.storage.OraclePrice\"));\n\n struct Props {\n EnumerableSet.AddressSet tokens;\n mapping(address => Data) tokenPrices;\n mapping(address => Data) preTokenPrices;\n EnumerableSet.Bytes32Set pairs;\n mapping(bytes32 => Data) pairPrices;\n }\n\n struct Data {\n int256 min;\n int256 max;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = _ORACLE_PRICE;\n assembly {\n self.slot := s\n }\n }\n\n function getPrice(Props storage oracle, address token) external view returns (Data memory) {\n return oracle.tokenPrices[token];\n }\n\n function getPrice(Props storage oracle, address token, address targetToken) external view returns (Data memory) {\n bytes32 pair = keccak256(abi.encode(token, targetToken));\n return oracle.pairPrices[pair];\n }\n\n function getPrePrice(Props storage oracle, address token) external view returns (Data memory) {\n return oracle.preTokenPrices[token];\n }\n\n function setPrice(Props storage oracle, address token, Data memory price) public {\n if (!oracle.tokens.contains(token)) {\n oracle.tokens.add(token);\n }\n oracle.tokenPrices[token] = price;\n }\n\n function setPrice(Props storage oracle, address token, address targetToken, Data memory price) public {\n bytes32 pair = keccak256(abi.encode(token, targetToken));\n if (!oracle.pairs.contains(pair)) {\n oracle.pairs.add(pair);\n }\n oracle.pairPrices[pair] = price;\n }\n\n function setPrePrice(Props storage oracle, address token, Data calldata price) external {\n if (!oracle.tokens.contains(token)) {\n oracle.tokens.add(token);\n }\n oracle.preTokenPrices[token] = price;\n }\n\n function clearAllPrice(Props storage oracle) external {\n address[] memory tokenAddrs = oracle.tokens.values();\n for (uint256 i; i < tokenAddrs.length; i++) {\n delete oracle.tokenPrices[tokenAddrs[i]];\n delete oracle.preTokenPrices[tokenAddrs[i]];\n oracle.tokens.remove(tokenAddrs[i]);\n }\n }\n}\n" + }, + "contracts/storage/Order.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary Order {\n bytes32 constant ORDER = keccak256(abi.encode(\"link.profile.storage.Order\"));\n\n enum PositionSide {\n NONE,\n INCREASE,\n DECREASE\n }\n\n enum Side {\n NONE,\n LONG,\n SHORT\n }\n\n enum Type {\n NONE,\n MARKET,\n LIMIT,\n STOP\n }\n\n enum StopType {\n NONE,\n STOP_LOSS,\n TAKE_PROFIT\n }\n\n struct Props {\n mapping(uint256 => OrderInfo) orders;\n }\n\n struct OrderInfo {\n address account;\n bytes32 symbol;\n Side orderSide;\n PositionSide posSide;\n Type orderType;\n StopType stopType;\n bool isCrossMargin;\n bool isExecutionFeeFromTradeVault;\n address marginToken;\n uint256 qty;\n uint256 leverage; //position leverage\n uint256 orderMargin;\n uint256 triggerPrice; // for limit & stop order\n uint256 acceptablePrice; //for market & stop order\n uint256 placeTime;\n uint256 executionFee;\n uint256 lastBlock;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = ORDER;\n assembly {\n self.slot := s\n }\n }\n\n function create(uint256 orderId) external view returns (OrderInfo storage) {\n Order.Props storage self = load();\n return self.orders[orderId];\n }\n\n function get(Order.Props storage self, uint256 orderId) external view returns (OrderInfo storage) {\n return self.orders[orderId];\n }\n\n function get(uint256 orderId) external view returns (OrderInfo storage) {\n Order.Props storage self = load();\n return self.orders[orderId];\n }\n\n function remove(Order.Props storage self, uint256 orderId) external {\n delete self.orders[orderId];\n }\n\n function remove(uint256 orderId) external {\n Order.Props storage self = load();\n delete self.orders[orderId];\n }\n\n function updateAllOrderLeverage(\n uint256[] memory orders,\n bytes32 symbol,\n address marginToken,\n uint256 leverage,\n bool isLong,\n bool isCrossMargin\n ) external {\n Order.Props storage self = load();\n for (uint256 i; i < orders.length; i++) {\n Order.OrderInfo storage orderInfo = self.orders[orders[i]];\n bool isLongOrder = orderInfo.orderSide == Order.Side.LONG;\n if (\n orderInfo.isCrossMargin == isCrossMargin &&\n orderInfo.symbol == symbol &&\n orderInfo.marginToken == marginToken &&\n ((isLongOrder == isLong && orderInfo.posSide == Order.PositionSide.INCREASE) ||\n (isLongOrder != isLong && orderInfo.posSide == Order.PositionSide.DECREASE))\n ) {\n orderInfo.leverage = leverage;\n }\n }\n }\n\n function hasOtherShortOrders(\n uint256[] memory orders,\n bytes32 symbol,\n address marginToken,\n bool isCrossMargin\n ) external view returns (bool) {\n Order.Props storage self = load();\n for (uint256 i; i < orders.length; i++) {\n Order.OrderInfo storage orderInfo = self.orders[orders[i]];\n if (\n orderInfo.symbol == symbol &&\n orderInfo.marginToken != marginToken &&\n orderInfo.isCrossMargin == isCrossMargin &&\n orderInfo.posSide == Order.PositionSide.INCREASE &&\n orderInfo.orderSide == Order.Side.SHORT\n ) {\n return true;\n }\n }\n return false;\n }\n}\n" + }, + "contracts/storage/PermissionFlag.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nlibrary PermissionFlag {\n\n bytes32 public constant ALL_PERMISSION_FLAG = keccak256(\"ALL_PERMISSION_FLAG\");\n bytes32 public constant MINT_PERMISSION_FLAG = keccak256(\"MINT_PERMISSION_FLAG\");\n bytes32 public constant BURN_PERMISSION_FLAG = keccak256(\"BURN_PERMISSION_FLAG\");\n bytes32 public constant DEPOSIT_PERMISSION_FLAG = keccak256(\"DEPOSIT_PERMISSION_FLAG\");\n bytes32 public constant WITHDRAW_PERMISSION_FLAG = keccak256(\"WITHDRAW_PERMISSION_FLAG\");\n bytes32 public constant ORDER_PERMISSION_FLAG = keccak256(\"ORDER_PERMISSION_FLAG\");\n\n using EnumerableSet for EnumerableSet.AddressSet;\n\n struct Props {\n EnumerableSet.AddressSet allowSet;\n EnumerableSet.AddressSet denySet;\n }\n\n error AddressDenied(address to);\n\n function load(bytes32 featureKey) public pure returns(Props storage self){\n bytes32 s = keccak256(abi.encode(\"link.profit.storage.Permission\", featureKey));\n assembly {\n self.slot := s\n } \n }\n\n function isAllowed(bytes32 featureKey, address to) external view returns (bool){\n Props storage permission = load(featureKey);\n return permission.allowSet.contains(to);\n }\n\n function isDenied(bytes32 featureKey, address to) external view returns (bool) {\n Props storage permission = load(featureKey);\n return permission.denySet.contains(to);\n }\n\n function validDenied(bytes32 featureKey, address to) external view {\n Props storage permission = load(featureKey);\n if(permission.denySet.contains(to)) {\n revert AddressDenied(to);\n }\n }\n\n\n}" + }, + "contracts/storage/Position.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary Position {\n using EnumerableSet for EnumerableSet.AddressSet;\n using SafeCast for uint256;\n\n struct Props {\n bytes32 key;\n bytes32 symbol;\n bool isLong;\n bool isCrossMargin;\n address account;\n address marginToken;\n address indexToken;\n uint256 qty;\n uint256 entryPrice;\n uint256 leverage;\n uint256 initialMargin;\n uint256 initialMarginInUsd;\n uint256 initialMarginInUsdFromBalance;\n uint256 holdPoolAmount;\n PositionFee positionFee;\n int256 realizedPnl;\n uint256 lastUpdateTime;\n }\n\n struct PositionFee {\n uint256 closeFeeInUsd;\n uint256 openBorrowingFeePerToken;\n uint256 realizedBorrowingFee;\n uint256 realizedBorrowingFeeInUsd;\n int256 openFundingFeePerQty;\n int256 realizedFundingFee;\n int256 realizedFundingFeeInUsd;\n }\n\n enum PositionUpdateFrom {\n NONE,\n ORDER_INCREASE,\n ORDER_DECREASE,\n ADD_MARGIN,\n DECREASE_MARGIN,\n INCREASE_LEVERAGE,\n DECREASE_LEVERAGE,\n LIQUIDATION\n }\n\n event PositionUpdateEvent(\n uint256 requestId,\n bytes32 positionKey,\n PositionUpdateFrom from,\n Props position,\n uint256 executePrice\n );\n\n function load(\n address account,\n bytes32 symbol,\n address marginToken,\n bool isCrossMargin\n ) public pure returns (Props storage position) {\n return load(getPositionKey(account, symbol, marginToken, isCrossMargin));\n }\n\n function load(bytes32 key) public pure returns (Props storage self) {\n assembly {\n self.slot := key\n }\n }\n\n function getPositionKey(\n address account,\n bytes32 symbol,\n address marginToken,\n bool isCrossMargin\n ) public pure returns (bytes32) {\n return keccak256(abi.encode(\"link.profile.storage.Position\", account, symbol, marginToken, isCrossMargin));\n }\n\n function hasPosition(Props storage self) external view returns (bool) {\n return self.qty > 0;\n }\n\n function checkExists(Props storage self) external view {\n if (self.qty == 0) {\n revert Errors.PositionNotExists();\n }\n }\n\n function reset(Props storage self) external {\n self.qty = 0;\n self.entryPrice = 0;\n self.leverage = 0;\n self.initialMargin = 0;\n self.initialMarginInUsd = 0;\n self.initialMarginInUsdFromBalance = 0;\n self.holdPoolAmount = 0;\n self.positionFee.closeFeeInUsd = 0;\n self.realizedPnl = 0;\n self.positionFee.closeFeeInUsd = 0;\n self.positionFee.openBorrowingFeePerToken = 0;\n self.positionFee.realizedBorrowingFee = 0;\n self.positionFee.realizedBorrowingFeeInUsd = 0;\n self.positionFee.openFundingFeePerQty = 0;\n self.positionFee.realizedFundingFee = 0;\n self.positionFee.realizedFundingFeeInUsd = 0;\n }\n\n function emitPositionUpdateEvent(Props storage self, uint256 requestId, PositionUpdateFrom from, uint256 executePrice) external {\n emit PositionUpdateEvent(\n requestId,\n getPositionKey(self.account, self.symbol, self.marginToken, self.isCrossMargin),\n from,\n self,\n executePrice\n );\n }\n\n}\n" + }, + "contracts/storage/Redeem.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nlibrary Redeem {\n \n bytes32 constant REDEEM_KEY = keccak256(abi.encode(\"link.profile.storage.Redeem\"));\n\n struct Props {\n mapping(uint256 => Request) requests;\n }\n\n struct Request {\n address account;\n address receiver;\n address stakeToken;\n address redeemToken;\n uint256 unStakeAmount;\n uint256 minRedeemAmount;\n uint256 executionFee;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = REDEEM_KEY;\n assembly {\n self.slot := s\n }\n }\n\n function create(uint256 requestId) external view returns (Request storage) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function get(uint256 requestId) external view returns (Request memory) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function remove(uint256 requestId) external {\n Props storage self = load();\n delete self.requests[requestId];\n }\n}\n" + }, + "contracts/storage/RoleAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary RoleAccessControl {\n using EnumerableSet for EnumerableSet.Bytes32Set;\n\n bytes32 internal constant ACCESS_CONTROL_KEY = keccak256(abi.encode(\"link.profile.storage.AccessControl\"));\n\n bytes32 constant ROLE_ADMIN = \"ADMIN\";\n bytes32 constant ROLE_CONFIG = \"CONFIG\";\n bytes32 constant ROLE_KEEPER = \"KEEPER\";\n\n struct Props {\n mapping(address => EnumerableSet.Bytes32Set) accountRoles;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = ACCESS_CONTROL_KEY;\n assembly {\n self.slot := s\n }\n }\n\n function checkRole(bytes32 role) internal view {\n if (!hasRole(msg.sender, role)) {\n revert Errors.InvalidRoleAccess(msg.sender, role);\n }\n }\n\n function hasRole(bytes32 role) internal view returns (bool) {\n return hasRole(msg.sender, role);\n }\n\n function hasRole(address account, bytes32 role) internal view returns (bool) {\n Props storage self = load();\n return self.accountRoles[account].contains(role);\n }\n\n function grantRole(address account, bytes32 role) internal {\n Props storage self = load();\n self.accountRoles[account].add(role);\n }\n\n function revokeRole(address account, bytes32 role) internal {\n Props storage self = load();\n if (self.accountRoles[account].contains(role)) {\n self.accountRoles[account].remove(role);\n }\n }\n\n function revokeAllRole(address account) internal {\n Props storage self = load();\n delete self.accountRoles[account];\n }\n}\n" + }, + "contracts/storage/StakingAccount.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"./LpPool.sol\";\nimport \"hardhat/console.sol\";\n\nlibrary StakingAccount {\n using EnumerableSet for EnumerableSet.AddressSet;\n using LpPool for LpPool.Props;\n\n struct Props {\n address owner;\n EnumerableSet.AddressSet stakeTokens;\n mapping(address => Balance) stakeTokenBalances;\n mapping(address => FeeRewards) feeRewards;\n uint256 stakeUsdAmount;\n }\n\n struct FeeRewards {\n uint256 realisedRewardsTokenAmount;\n uint256 openRewardsPerStakeToken;\n }\n\n struct Balance {\n uint256 stakeAmount;\n EnumerableSet.AddressSet collateralTokens;\n mapping(address => CollateralData) collateralDatas;\n }\n\n struct CollateralData {\n uint256 amount;\n uint256 stakeLiability;\n }\n event StakingAccountCollateralUpdateEvent(\n address account,\n address stakeToken,\n address collateral,\n uint256 preAmount,\n uint256 preLiability,\n uint256 amount,\n uint256 liability\n );\n\n function load(address owner) public pure returns (Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profile.storage.StakingAccount\", owner));\n assembly {\n self.slot := s\n }\n }\n\n function addStakeAmount(Props storage self, address stakeToken, uint256 amount) external {\n if (self.stakeTokens.contains(stakeToken)) {\n self.stakeTokenBalances[stakeToken].stakeAmount = self.stakeTokenBalances[stakeToken].stakeAmount + amount;\n } else {\n self.stakeTokens.add(stakeToken);\n self.stakeTokenBalances[stakeToken].stakeAmount = amount;\n }\n }\n\n function subStakeAmount(Props storage self, address stakeToken, uint256 amount) external {\n require(self.stakeTokenBalances[stakeToken].stakeAmount >= amount, \"token amount not enough\");\n self.stakeTokenBalances[stakeToken].stakeAmount = self.stakeTokenBalances[stakeToken].stakeAmount - amount;\n }\n\n function addStakeLiability(\n Props storage self,\n address stakeToken,\n address collateralToken,\n uint256 liability\n ) external {\n if (!self.stakeTokens.contains(stakeToken)) {\n self.stakeTokens.add(stakeToken);\n }\n if (!self.stakeTokenBalances[stakeToken].collateralTokens.contains(collateralToken)) {\n self.stakeTokenBalances[stakeToken].collateralTokens.add(collateralToken);\n }\n CollateralData storage data = self.stakeTokenBalances[stakeToken].collateralDatas[collateralToken];\n uint256 preLiability = data.stakeLiability;\n data.stakeLiability += liability;\n emit StakingAccountCollateralUpdateEvent(\n self.owner,\n stakeToken,\n collateralToken,\n data.amount,\n preLiability,\n data.amount,\n data.stakeLiability\n );\n }\n\n function subStakeLiability(\n Props storage self,\n address stakeToken,\n address collateralToken,\n uint256 liability\n ) external {\n require(\n self.stakeTokens.contains(stakeToken) &&\n self.stakeTokenBalances[stakeToken].collateralTokens.contains(collateralToken),\n \"stake liability not enough\"\n );\n require(\n self.stakeTokenBalances[stakeToken].collateralDatas[collateralToken].stakeLiability >= liability,\n \"stake liability not enough\"\n );\n CollateralData storage data = self.stakeTokenBalances[stakeToken].collateralDatas[collateralToken];\n uint256 preLiability = data.stakeLiability;\n data.stakeLiability -= liability;\n emit StakingAccountCollateralUpdateEvent(\n self.owner,\n stakeToken,\n collateralToken,\n data.amount,\n preLiability,\n data.amount,\n data.stakeLiability\n );\n }\n\n function addCollateralToken(\n Props storage self,\n address stakeToken,\n address collateralToken,\n uint256 amount\n ) external {\n if (!self.stakeTokens.contains(stakeToken)) {\n self.stakeTokens.add(stakeToken);\n }\n if (!self.stakeTokenBalances[stakeToken].collateralTokens.contains(collateralToken)) {\n self.stakeTokenBalances[stakeToken].collateralTokens.add(collateralToken);\n }\n CollateralData storage data = self.stakeTokenBalances[stakeToken].collateralDatas[collateralToken];\n uint256 preAmount = data.amount;\n data.amount += amount;\n emit StakingAccountCollateralUpdateEvent(\n self.owner,\n stakeToken,\n collateralToken,\n preAmount,\n data.stakeLiability,\n data.amount,\n data.stakeLiability\n );\n }\n\n function subCollateralToken(\n Props storage self,\n address stakeToken,\n address collateralToken,\n uint256 amount\n ) external {\n require(\n self.stakeTokens.contains(stakeToken) &&\n self.stakeTokenBalances[stakeToken].collateralTokens.contains(collateralToken),\n \"stake amount not enough\"\n );\n require(\n self.stakeTokenBalances[stakeToken].collateralDatas[collateralToken].amount >= amount,\n \"stake amount not enough\"\n );\n CollateralData storage data = self.stakeTokenBalances[stakeToken].collateralDatas[collateralToken];\n uint256 preAmount = data.amount;\n data.amount -= amount;\n emit StakingAccountCollateralUpdateEvent(\n self.owner,\n stakeToken,\n collateralToken,\n preAmount,\n data.stakeLiability,\n data.amount,\n data.stakeLiability\n );\n }\n\n function hasCollateralToken(Props storage self, address stakeToken) external view returns (bool) {\n if (!self.stakeTokens.contains(stakeToken)) {\n return false;\n }\n address[] memory tokens = self.stakeTokenBalances[stakeToken].collateralTokens.values();\n uint256 totalAmount = 0;\n for (uint256 i; i < tokens.length; i++) {\n totalAmount += self.stakeTokenBalances[stakeToken].collateralDatas[tokens[i]].amount;\n }\n return totalAmount > 0;\n }\n\n function getCollateralTokens(Props storage self, address stakeToken) external view returns (address[] memory) {\n return self.stakeTokenBalances[stakeToken].collateralTokens.values();\n }\n\n function getCollateralToken(\n Props storage self,\n address stakeToken,\n address collateralToken\n ) external view returns (CollateralData memory) {\n return self.stakeTokenBalances[stakeToken].collateralDatas[collateralToken];\n }\n\n function getSortedCollateralToken(Props storage self, address stakeToken) external view returns (address[] memory) {\n LpPool.Props storage pool = LpPool.load(stakeToken);\n address[] memory tokens = self.stakeTokenBalances[stakeToken].collateralTokens.values();\n Config.StakeCollateralConfig[] memory collateralConfigs = new Config.StakeCollateralConfig[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n collateralConfigs[i] = pool.getStakeCollateralConfig(tokens[i]);\n }\n if (collateralConfigs.length > 1) {\n for (uint i = 1; i < collateralConfigs.length; i++) {\n Config.StakeCollateralConfig memory temp = collateralConfigs[i];\n address tempToken = tokens[i];\n uint j = i;\n while ((j >= 1) && (temp.discount < collateralConfigs[j - 1].discount)) {\n collateralConfigs[j] = collateralConfigs[j - 1];\n tokens[j] = tokens[j - 1];\n j--;\n }\n collateralConfigs[j] = temp;\n tokens[j] = tempToken;\n }\n }\n return tokens;\n }\n\n function addStakeUsdAmount(Props storage self, uint256 amount) external {\n self.stakeUsdAmount = self.stakeUsdAmount + amount;\n }\n\n function subStakeUsdAmount(Props storage self, uint256 amount) external {\n require(self.stakeUsdAmount >= amount, \"usd token amount not enough\");\n self.stakeUsdAmount = self.stakeUsdAmount - amount;\n }\n\n function getStakeTokens(Props storage self) external view returns(address[] memory) {\n return self.stakeTokens.values();\n }\n\n function getFeeRewards(Props storage self, address stakeToken) external view returns(FeeRewards storage){\n return self.feeRewards[stakeToken];\n }\n}\n" + }, + "contracts/storage/Symbol.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary Symbol {\n enum Status {\n OPEN,\n PAUSE,\n REDUCE_ONLY,\n SETTLED\n }\n\n struct Props {\n bytes32 code;\n Status status;\n address stakeToken;\n address indexToken;\n address baseToken;\n string baseTokenName;\n }\n\n function create(bytes32 code) external returns (Props storage self) {\n self = load(code);\n self.code = code;\n }\n\n function load(bytes32 code) public pure returns (Props storage self) {\n bytes32 s = keccak256(abi.encode(\"link.profile.storage.Symbol\", code));\n\n assembly {\n self.slot := s\n }\n }\n\n function isSupportIncreaseOrder(Props storage self) external view returns (bool) {\n return self.status == Status.OPEN;\n }\n}\n" + }, + "contracts/storage/UpdateLeverage.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary UpdateLeverage {\n bytes32 constant KEY = keccak256(abi.encode(\"link.profile.storage.UpdateLeverage\"));\n\n struct Props {\n mapping(uint256 => Request) requests;\n }\n\n struct Request {\n address account;\n bytes32 symbol;\n bool isLong;\n bool isExecutionFeeFromTradeVault;\n bool isCrossMargin;\n uint256 leverage;\n address marginToken;\n uint256 addMarginAmount;\n uint256 executionFee;\n uint256 lastBlock;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = KEY;\n assembly {\n self.slot := s\n }\n }\n\n function create(uint256 requestId) external view returns (Request storage) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function get(uint256 requestId) external view returns (Request memory) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function remove(uint256 requestId) external {\n Props storage self = load();\n delete self.requests[requestId];\n }\n}\n" + }, + "contracts/storage/UpdatePositionMargin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nlibrary UpdatePositionMargin {\n bytes32 constant KEY = keccak256(abi.encode(\"link.profile.storage.UpdatePositionMargin\"));\n\n struct Props {\n mapping(uint256 => Request) requests;\n }\n\n struct Request {\n address account;\n bytes32 positionKey;\n address marginToken;\n uint256 updateMarginAmount;\n uint256 executionFee;\n bool isAdd;\n bool isExecutionFeeFromTradeVault;\n uint256 lastBlock;\n\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = KEY;\n assembly {\n self.slot := s\n }\n }\n\n function create(uint256 requestId) external view returns (Request storage) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function get(uint256 requestId) external view returns (Request memory) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function remove(uint256 requestId) external {\n Props storage self = load();\n delete self.requests[requestId];\n }\n}\n" + }, + "contracts/storage/UsdPool.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"../utils/CalUtils.sol\";\nimport \"../utils/ChainUtils.sol\";\nimport \"./Config.sol\";\n\nlibrary UsdPool {\n bytes32 private constant _KEY = keccak256(abi.encode(\"link.profile.storage.UsdPool\"));\n\n using EnumerableSet for EnumerableSet.AddressSet;\n using SafeMath for uint256;\n using SafeCast for uint256;\n using Config for Config.Props;\n\n struct Props {\n EnumerableSet.AddressSet stableTokens;\n mapping(address => TokenBalance) stableTokenBalances;\n mapping(address => BorrowingFee) borrowingFees;\n uint256 apr;\n }\n\n struct TokenBalance {\n uint256 amount;\n uint256 holdAmount;\n uint256 unsettledAmount;\n }\n\n struct BorrowingFee {\n uint256 totalBorrowingFee;\n uint256 totalRealizedBorrowingFee;\n uint256 cumulativeBorrowingFeePerToken;\n uint256 lastUpdateTime;\n }\n\n struct UsdPoolTokenUpdateCache {\n address token;\n uint256 preAmount;\n uint256 preHoldAmount;\n uint256 preUnsettledAmount;\n uint256 amount;\n uint256 holdAmount;\n uint256 unsettledAmount;\n uint256 updateBlock;\n }\n\n event UsdPoolTokenUpdateEvent(\n address token,\n uint256 preAmount,\n uint256 preHoldAmount,\n uint256 preUnsettledAmount,\n uint256 amount,\n uint256 holdAmount,\n uint256 unsettledAmount,\n uint256 updateBlock\n );\n\n function load() public pure returns (Props storage self) {\n bytes32 s = _KEY;\n\n assembly {\n self.slot := s\n }\n }\n\n function getUsdPoolConfig() internal view returns (Config.UsdPoolConfig storage) {\n return Config.load().getUsdPoolConfig();\n }\n\n function addStableToken(Props storage self, address stableToken, uint amount) external {\n require(self.stableTokens.contains(stableToken), \"stable token not supported!\");\n UsdPoolTokenUpdateCache memory cache = _convertBalanceToCache(\n stableToken,\n self.stableTokenBalances[stableToken]\n );\n self.stableTokenBalances[stableToken].amount += amount;\n cache.amount = self.stableTokenBalances[stableToken].amount;\n _emitPoolUpdateEvent(cache);\n }\n\n function subStableToken(Props storage self, address stableToken, uint amount) external {\n require(isSubAmountAllowed(self, stableToken, amount), \"sub failed with balance not enough\");\n UsdPoolTokenUpdateCache memory cache = _convertBalanceToCache(\n stableToken,\n self.stableTokenBalances[stableToken]\n );\n self.stableTokenBalances[stableToken].amount -= amount;\n cache.amount = self.stableTokenBalances[stableToken].amount;\n _emitPoolUpdateEvent(cache);\n }\n\n function holdStableToken(Props storage self, address stableToken, uint amount) external {\n require(\n isHoldAmountAllowed(self.stableTokenBalances[stableToken], getPoolLiquidityLimit(), amount),\n \"hold failed with balance not enough\"\n );\n UsdPoolTokenUpdateCache memory cache = _convertBalanceToCache(\n stableToken,\n self.stableTokenBalances[stableToken]\n );\n self.stableTokenBalances[stableToken].holdAmount += amount;\n cache.holdAmount = self.stableTokenBalances[stableToken].holdAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function unHoldStableToken(Props storage self, address stableToken, uint256 amount) external {\n require(self.stableTokenBalances[stableToken].holdAmount >= amount, \"sub hold bigger than hold\");\n UsdPoolTokenUpdateCache memory cache = _convertBalanceToCache(\n stableToken,\n self.stableTokenBalances[stableToken]\n );\n self.stableTokenBalances[stableToken].holdAmount -= amount;\n cache.holdAmount = self.stableTokenBalances[stableToken].holdAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function addUnsettleStableToken(Props storage self, address stableToken, uint256 amount) external {\n UsdPoolTokenUpdateCache memory cache = _convertBalanceToCache(\n stableToken,\n self.stableTokenBalances[stableToken]\n );\n self.stableTokenBalances[stableToken].unsettledAmount += amount;\n cache.unsettledAmount = self.stableTokenBalances[stableToken].unsettledAmount;\n _emitPoolUpdateEvent(cache);\n }\n\n function settleStableToken(Props storage self, address stableToken, uint256 amount, bool updateAmount) external {\n if (!self.stableTokens.contains(stableToken)) {\n self.stableTokens.add(stableToken);\n }\n TokenBalance storage balance = self.stableTokenBalances[stableToken];\n require(balance.unsettledAmount >= amount, \"xUsd settle stable token overflow!\");\n UsdPoolTokenUpdateCache memory cache = _convertBalanceToCache(stableToken, balance);\n balance.unsettledAmount -= amount;\n cache.unsettledAmount = balance.unsettledAmount;\n if (updateAmount) {\n balance.amount += amount;\n cache.amount = balance.amount;\n }\n _emitPoolUpdateEvent(cache);\n }\n\n function addSupportStableTokens(Props storage self, address[] memory stableTokens) external {\n for (uint256 i; i < stableTokens.length; i++) {\n self.stableTokens.add(stableTokens[i]);\n }\n }\n\n function removeSupportStableToken(Props storage self, address stableToken) external {\n self.stableTokens.remove(stableToken);\n }\n\n function getPoolLiquidityLimit() public view returns (uint256) {\n return getUsdPoolConfig().poolLiquidityLimit;\n }\n\n function getBorrowingFees(Props storage self, address stableToken) external view returns (BorrowingFee storage) {\n return self.borrowingFees[stableToken];\n }\n\n function getStableTokens(Props storage self) external view returns (address[] memory) {\n return self.stableTokens.values();\n }\n\n function getSupportedStableTokens() external view returns (address[] memory) {\n Props storage self = load();\n return self.stableTokens.values();\n }\n\n function isSupportStableToken(address stableToken) external view returns (bool) {\n Props storage self = load();\n return self.stableTokens.contains(stableToken);\n }\n\n function getStableTokenBalance(\n Props storage self,\n address stableToken\n ) external view returns (TokenBalance memory) {\n return self.stableTokenBalances[stableToken];\n }\n\n function getStableTokenBalanceArray(Props storage self) external view returns (TokenBalance[] memory) {\n address[] memory tokens = self.stableTokens.values();\n TokenBalance[] memory balances = new TokenBalance[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n balances[i] = self.stableTokenBalances[tokens[i]];\n }\n return balances;\n }\n\n function getAllBorrowingFees(Props storage self) external view returns (BorrowingFee[] memory) {\n address[] memory tokens = self.stableTokens.values();\n BorrowingFee[] memory fees = new BorrowingFee[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n fees[i] = self.borrowingFees[tokens[i]];\n }\n return fees;\n }\n\n function getMaxWithdrawArray(Props storage self) external view returns (uint256[] memory) {\n address[] memory tokens = self.stableTokens.values();\n uint256[] memory maxWithdraws = new uint256[](tokens.length);\n for (uint256 i; i < tokens.length; i++) {\n maxWithdraws[i] = getMaxWithdraw(self, tokens[i]);\n }\n return maxWithdraws;\n }\n\n function getMaxWithdraw(Props storage self, address stableToken) public view returns (uint256) {\n TokenBalance storage balance = self.stableTokenBalances[stableToken];\n uint256 poolLiquidityLimit = getPoolLiquidityLimit();\n if (poolLiquidityLimit == 0) {\n return balance.amount - balance.holdAmount;\n } else {\n return balance.amount - CalUtils.divRate(balance.holdAmount, poolLiquidityLimit);\n }\n }\n\n function getMaxAmountStableToken(Props storage self) external view returns (address token) {\n address[] memory tokens = self.stableTokens.values();\n uint256 maxAmount;\n for (uint256 i; i < tokens.length; i++) {\n if (self.stableTokenBalances[tokens[i]].amount >= maxAmount) {\n maxAmount = self.stableTokenBalances[tokens[i]].amount;\n token = tokens[i];\n }\n }\n }\n\n function isSubAmountAllowed(Props storage self, address stableToken, uint256 amount) public view returns (bool) {\n TokenBalance storage balance = self.stableTokenBalances[stableToken];\n if (balance.amount < amount) {\n return false;\n }\n uint256 poolLiquidityLimit = getPoolLiquidityLimit();\n if (poolLiquidityLimit == 0) {\n return balance.amount - balance.holdAmount >= amount;\n } else {\n return CalUtils.mulRate(balance.amount - amount, poolLiquidityLimit) >= balance.holdAmount;\n }\n }\n\n function isHoldAmountAllowed(\n TokenBalance memory balance,\n uint256 poolLiquidityLimit,\n uint256 amount\n ) internal pure returns (bool) {\n if (poolLiquidityLimit == 0) {\n return balance.amount + balance.unsettledAmount - balance.holdAmount >= amount;\n } else {\n return\n CalUtils.mulRate(balance.amount + balance.unsettledAmount, poolLiquidityLimit) - balance.holdAmount >=\n amount;\n }\n }\n\n function _convertBalanceToCache(\n address token,\n TokenBalance storage balance\n ) internal view returns (UsdPoolTokenUpdateCache memory cache) {\n cache.token = token;\n cache.preAmount = balance.amount;\n cache.preHoldAmount = balance.holdAmount;\n cache.preUnsettledAmount = balance.unsettledAmount;\n cache.amount = balance.amount;\n cache.holdAmount = balance.holdAmount;\n cache.unsettledAmount = balance.unsettledAmount;\n cache.updateBlock = ChainUtils.currentBlock();\n }\n\n function _emitPoolUpdateEvent(UsdPoolTokenUpdateCache memory cache) internal {\n emit UsdPoolTokenUpdateEvent(\n cache.token,\n cache.preAmount,\n cache.preHoldAmount,\n cache.preUnsettledAmount,\n cache.amount,\n cache.holdAmount,\n cache.unsettledAmount,\n cache.updateBlock\n );\n }\n}\n" + }, + "contracts/storage/UuidCreator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nlibrary UuidCreator {\n bytes32 private constant _UUID_CREATOR = keccak256(abi.encode(\"link.profit.storage.UuidCreator\"));\n\n uint256 private constant MIN_ID = 1111;\n\n struct Props {\n mapping(bytes32 => uint256) lastIds;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = _UUID_CREATOR;\n\n assembly {\n self.slot := s\n }\n }\n\n function nextId(bytes32 key) external returns (uint256) {\n Props storage self = load();\n uint256 lastId = self.lastIds[key];\n if (lastId < MIN_ID) {\n lastId = MIN_ID + 1;\n } else {\n lastId++;\n }\n self.lastIds[key] = lastId;\n return lastId;\n }\n\n function getId(bytes32 key) external view returns (uint256) {\n Props storage self = load();\n return self.lastIds[key];\n }\n}\n" + }, + "contracts/storage/Withdraw.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n\nlibrary Withdraw {\n bytes32 constant WITHDRAW_KEY = keccak256(abi.encode(\"link.profile.storage.Withdraw\"));\n\n struct Props {\n mapping(uint256 => Request) requests;\n }\n\n struct Request {\n address account;\n address token;\n uint256 amount;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = WITHDRAW_KEY;\n assembly {\n self.slot := s\n }\n }\n\n function create(uint256 requestId) external view returns (Request storage) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function get(uint256 requestId) external view returns (Request memory) {\n Props storage self = load();\n return self.requests[requestId];\n }\n\n function remove(uint256 requestId) external {\n Props storage self = load();\n delete self.requests[requestId];\n }\n}\n" + }, + "contracts/utils/AddressUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary AddressUtils {\n uint256 public constant TEST = 1000;\n\n error AddressZero();\n\n function validEmpty(address addr) external pure {\n if (addr == address(0)) {\n revert AddressZero();\n }\n }\n\n function isEmpty(address addr) external pure returns (bool) {\n return addr == address(0);\n }\n\n}\n" + }, + "contracts/utils/CalUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedSafeMath.sol\";\n\nlibrary CalUtils {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeCast for int256;\n using SignedMath for int256;\n using SignedSafeMath for int256;\n\n uint256 public constant SMALL_RATE_PRECISION = 10 ** 18;\n\n uint256 public constant RATE_PRECISION = 100000;\n\n uint256 public constant PRICE_PRECISION = 10 ** 8;\n\n uint256 public constant PRICE_TO_WEI = 10 ** 10;\n\n uint256 public constant USD_PRECISION = 10 ** 18;\n\n function mulRate(uint256 value, uint256 rate) external pure returns (uint256) {\n return Math.mulDiv(value, rate, RATE_PRECISION);\n }\n\n function mulRate(int256 value, int256 rate) external pure returns (int256) {\n return value.mul(rate).div(RATE_PRECISION.toInt256());\n }\n\n function divRate(uint256 value, uint256 rate) external pure returns (uint256) {\n return Math.mulDiv(value, RATE_PRECISION, rate);\n }\n\n function divToPrecision(uint256 value1, uint256 value2, uint256 precision) external pure returns (uint256) {\n return Math.mulDiv(value1, precision, value2);\n }\n\n function mulSmallRate(uint256 value, uint256 rate) external pure returns (uint256) {\n return Math.mulDiv(value, rate, SMALL_RATE_PRECISION);\n }\n\n function mulIntSmallRate(int256 value, int256 rate) external pure returns (int256) {\n return value.mul(rate).div(SMALL_RATE_PRECISION.toInt256());\n }\n\n function divSmallRate(uint256 value, uint256 rate) external pure returns (uint256) {\n return Math.mulDiv(value, SMALL_RATE_PRECISION, rate);\n }\n\n function tokenToUsd(uint256 tokenAmount, uint8 tokenDecimals, uint256 tokenPrice) external pure returns (uint256) {\n return tokenAmount.mul(tokenPrice).mul(PRICE_TO_WEI).div(10 ** tokenDecimals);\n }\n\n function tokenToUsdInt(int256 tokenAmount, uint8 tokenDecimals, int256 tokenPrice) external pure returns (int256) {\n return tokenAmount.mul(tokenPrice).mul(PRICE_TO_WEI.toInt256()).div((10 ** tokenDecimals).toInt256());\n }\n\n function usdToToken(\n uint256 tokenUsdAmount,\n uint8 tokenDecimals,\n uint256 tokenPrice\n ) external pure returns (uint256) {\n return Math.mulDiv(tokenUsdAmount, 10 ** tokenDecimals, tokenPrice.mul(PRICE_TO_WEI));\n }\n\n function usdToTokenInt(\n int256 tokenUsdAmount,\n uint8 tokenDecimals,\n int256 tokenPrice\n ) external pure returns (int256) {\n return tokenUsdAmount.mul((10 ** tokenDecimals).toInt256()).div(tokenPrice.mul(PRICE_TO_WEI.toInt256()));\n }\n\n function tokenToToken(\n uint256 originTokenAmount,\n uint8 originTokenDecimals,\n uint8 targetTokenDecimals,\n uint256 tokenToTokenPrice\n ) external pure returns (uint256) {\n if (targetTokenDecimals >= originTokenDecimals) {\n return\n originTokenAmount.mul(tokenToTokenPrice).mul(10 ** (targetTokenDecimals - originTokenDecimals)).div(\n PRICE_PRECISION\n );\n } else {\n return\n originTokenAmount.mul(tokenToTokenPrice).div(PRICE_PRECISION).div(\n 10 ** (originTokenDecimals - targetTokenDecimals)\n );\n }\n }\n\n function tokenToToken(\n uint256 originTokenAmount,\n uint8 originTokenDecimals,\n uint8 targetTokenDecimals,\n uint256 originTokenPrice,\n uint256 targetTokenPrice\n ) external pure returns (uint256) {\n if (targetTokenDecimals >= originTokenDecimals) {\n return\n originTokenAmount.mul(originTokenPrice).mul(10 ** (targetTokenDecimals - originTokenDecimals)).div(\n targetTokenPrice\n );\n } else {\n return\n originTokenAmount.mul(originTokenPrice).div(targetTokenPrice).div(\n 10 ** (originTokenDecimals - targetTokenDecimals)\n );\n }\n }\n\n function decimalsToDecimals(\n uint256 value,\n uint8 originDecimals,\n uint8 targetDecimals\n ) external pure returns (uint256) {\n return Math.mulDiv(value, 10 ** targetDecimals, 10 ** originDecimals);\n }\n\n function computeAvgEntryPrice(\n uint256 qty,\n uint256 entryPrice,\n uint256 increaseQty,\n uint256 tokenPrice,\n uint256 tickSize,\n bool isUp\n ) external pure returns (uint256) {\n uint256 originEntryPrice = (qty.mul(entryPrice).add(increaseQty.mul(tokenPrice))).div(qty + increaseQty);\n return formatToTickSize(originEntryPrice, tickSize, isUp);\n }\n\n function formatToTickSize(uint256 value, uint256 tickSize, bool roundUp) public pure returns (uint256) {\n uint256 mod = value % tickSize;\n if (mod == 0) {\n return value;\n } else {\n return (value.div(tickSize).add((roundUp ? 1 : 0))).mul(tickSize);\n }\n }\n\n function diff(uint256 value1, uint256 value2) external pure returns (uint256) {\n return value1 > value2 ? value1 - value2 : value2 - value1;\n }\n}\n" + }, + "contracts/utils/ChainUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary ChainUtils {\n function currentTimestamp() external view returns (uint256) {\n return block.timestamp;\n }\n\n function currentBlock() external view returns (uint256) {\n return block.number;\n }\n}\n" + }, + "contracts/utils/CommonUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"./Errors.sol\";\n\nlibrary CommonUtils {\n\n function validBlockNumber(uint256 blockNo, uint256 minGap, uint256 maxGap) external view {\n uint256 lastBlockNo = block.number;\n if (lastBlockNo < blockNo + minGap) {\n revert Errors.BlockNumberInvalid();\n }\n if (maxGap > 0 && lastBlockNo > blockNo + maxGap) {\n revert Errors.BlockNumberInvalid();\n }\n }\n\n function validMinBlockNumber(uint256 blockNo, uint256 minGap) external view {\n uint256 lastBlockNo = block.number;\n if (lastBlockNo < blockNo + minGap) {\n revert Errors.BlockNumberInvalid();\n }\n }\n\n}" + }, + "contracts/utils/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary Errors {\n // common\n error AddressSelfNotSupported(address self);\n error AmountNotMatch(uint256 amount1, uint256 amount2);\n error AmountZeroNotAllowed();\n error PriceIsZero();\n error UnknownError(bytes msg);\n error InvalidRoleAccess(address account, bytes32 role);\n error InvalidRoleName(bytes32 role);\n error ExecutionFeeNotEnough();\n error BlockNumberInvalid();\n\n // transfer\n error BalanceNotEnough(address account, address token);\n error WithdrawWithNoEnoughAmount();\n error WithdrawRequestNotExists();\n error WithdrawNotAllowed();\n error TokenTransferError(address token, address receiver, uint256 amount);\n error TransferErrorWithVaultBalanceNotEnough(address vault, address token, address receiver, uint256 amount);\n error IgnoreSwapWithAccountLiabilityZero();\n\n // market\n error CreateSymbolExists(bytes32 code);\n error CreateStakePoolExists(address stakeToken);\n error SymbolNotExists();\n error SymbolStatusInvalid(bytes32 symbol);\n error StakeTokenInvalid(address stakeToken);\n error PoolNotExists();\n error PoolValueLessThanZero();\n error PoolAmountNotEnough(address stakeToken, address token);\n error PoolUnsettledAmountInvalid();\n\n // tokens\n error TokenIsNotSupport();\n error TokenIsNotSupportCollateral();\n error OnlyCollateralSupported();\n error OnlyIsolateSupported();\n error OnlyCrossSupported();\n error CollateralUserCapOverflow(address token, uint256 cap);\n error CollateralTotalCapOverflow(address token, uint256 cap);\n\n // account\n error AccountNotExist();\n\n // mint\n error MintRequestNotExists();\n error MintTokenInvalid(address stakeToken, address mintToken);\n error MintFailedWithBalanceNotEnough(address account, address baseToken);\n error MintStakeTokenTooSmall(uint256 minStakeAmount, uint256 realStakeAmount);\n error MintWithAmountZero();\n error PoolValueIsZero();\n error MintWithParamError();\n error MintCollateralNotSupport();\n error MintCollateralOverflow();\n error MintCollateralFailedWithPriceCloseToDiscount();\n \n\n // redeem\n error RedeemRequestNotExists();\n error RedeemTokenInvalid(address stakeToken, address mintToken);\n error RedeemCollateralNotSupport();\n error RedeemWithAmountEmpty(address account, address stakeToken);\n error RedeemWithAmountNotEnough(address account, address stakeToken);\n error RedeemStakeTokenTooSmall(uint256 redeemAmount);\n error RedeemReduceStakeTokenTooSmall();\n error RedeemWithVaultBalanceNotEnough(address vaultAddr, uint256 amount);\n\n // orders\n error OrderNotExists(uint256 orderId);\n error LeverageInvalid(bytes32 symbol, uint256 leverage);\n error OrderMarginTooSmall();\n error ReducePositionTooSmall(bytes32 symbol, address account);\n error DecreasePositionNotExists(bytes32 symbol, address account, address marginToken);\n error DecreaseQtyTooBig(bytes32 symbol, address account);\n error DecreaseOrderSideInvalid();\n error TokenInvalid(bytes32 symbol, address token);\n error PlaceOrderWithParamsError();\n error ExecutionFeeLessThanConfigGasFeeLimit();\n error ExecutionPriceInvalid();\n error ChangeCrossModeError(address account);\n error CancelOrderWithLiquidation(bytes32 symbol, address account);\n error OnlyDecreaseOrderSupported();\n\n // positions\n error PositionTooBig(bytes32 symbol, address account);\n error OnlyOneShortPositionSupport(bytes32 symbol);\n error MaxOILimited(bytes32 symbol, bool isLong);\n error OIRatioLimited();\n error PositionNotExists();\n error UpdatePositionMarginRequestNotExists();\n error AddMarginTooBig();\n error ReduceMarginTooBig();\n error PositionShouldBeLiquidation();\n error UpdateLeverageRequestNotExists();\n error UpdateLeverageWithNoChange();\n error UpdateLeverageError(\n address account,\n bytes32 symbol,\n bool isLong,\n uint256 existsLeverage,\n uint256 newLeverage\n );\n error LiquidationIgnored(address account);\n\n // fee\n error ClaimRewardsRequestNotExists();\n error ClaimTokenNotSupported();\n}\n" + }, + "contracts/utils/RoleKeys.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary RoleKeys {\n\n bytes32 public constant ADMIN_ROLE = keccak256(\"ADMIN_ROLE\");\n\n bytes32 public constant CONFIG_ROLE = keccak256(\"CONFIG_ROLE\");\n\n bytes32 public constant ORDER_ROLE = keccak256(\"ORDER_ROLE\");\n\n bytes32 public constant HANDLER_ROLE = keccak256(\"HANDLER_ROLE\");\n\n \n}" + }, + "contracts/utils/TokenUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nlibrary TokenUtils {\n function decimals(address token) external view returns (uint8) {\n return IERC20Metadata(token).decimals();\n }\n\n function totalSupply(address token) external view returns (uint256) {\n return IERC20(token).totalSupply();\n }\n}\n" + }, + "contracts/utils/TransferUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary TransferUtils {\n uint256 private constant _TRANSFER_GAS_LIMIT = 100000;\n\n function transfer(address token, address receiver, uint256 amount) external {\n if (amount == 0) {\n return;\n }\n\n (bool success, ) = nonRevertingTransferWithGasLimit(IERC20(token), receiver, amount, _TRANSFER_GAS_LIMIT);\n\n if (success) {\n return;\n }\n\n revert Errors.TokenTransferError(token, receiver, amount);\n }\n\n function nonRevertingTransferWithGasLimit(\n IERC20 token,\n address to,\n uint256 amount,\n uint256 gasLimit\n ) internal returns (bool, bytes memory) {\n bytes memory data = abi.encodeWithSelector(token.transfer.selector, to, amount);\n (bool success, bytes memory returndata) = address(token).call{ gas: gasLimit }(data);\n\n if (success) {\n // some tokens do not revert on a failed transfer, they will return a boolean instead\n // validate that the returned boolean is true, otherwise indicate that the token transfer failed\n if (returndata.length > 0 && !abi.decode(returndata, (bool))) {\n return (false, returndata);\n }\n\n // transfers on some tokens do not return a boolean value, they will just revert if a transfer fails\n // for these tokens, if success is true then the transfer should have completed\n return (true, returndata);\n }\n\n return (false, returndata);\n }\n}\n" + }, + "contracts/utils/TypeUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary TypeUtils {\n\n error Bytes32Empty();\n error StringEmpty();\n error IntZero();\n\n function bytes32Equals(bytes32 a, bytes32 b) external pure returns (bool) {\n if (a.length != b.length) \n return false;\n for (uint256 i; i < a.length; i++) {\n if (a[i] != b[i])\n return false;\n } \n return true; \n }\n \n function isBytes32Empty(bytes32 data) external pure returns (bool){\n return data.length == 0;\n }\n\n function validNotZero(uint data) external pure {\n if (data == 0) {\n revert IntZero();\n }\n }\n\n function validBytes32Empty(bytes32 data) external pure {\n if (data.length == 0) {\n revert Bytes32Empty();\n }\n }\n\n function validStringEmpty(string memory data) external pure {\n if (bytes(data).length == 0) {\n revert StringEmpty();\n }\n }\n\n\n}" + }, + "contracts/vault/LpVault.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"./Vault.sol\";\n\ncontract LpVault is Vault {\n \n}" + }, + "contracts/vault/PortfolioVault.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"./Vault.sol\";\n\ncontract PortfolioVault is Vault {\n \n}" + }, + "contracts/vault/StakeToken.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./Vault.sol\";\nimport \"../utils/RoleKeys.sol\";\n\ncontract StakeToken is ERC20, Vault {\n uint8 tokenTecimals = 18;\n\n constructor(string memory symbol_, uint8 _decimals) ERC20(\"Stake token\", symbol_) {\n tokenTecimals = _decimals;\n }\n\n // function mint(address account, uint256 amount) external onlyRole(RoleKeys.HANDLER_ROLE) {\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n }\n\n // function burn(address account, uint256 amount) external onlyRole(RoleKeys.HANDLER_ROLE) {\n function burn(address account, uint256 amount) external {\n _burn(account, amount);\n }\n\n function decimals() public view override returns (uint8) {\n return tokenTecimals;\n }\n}\n" + }, + "contracts/vault/TradeVault.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"./Vault.sol\";\n\ncontract TradeVault is Vault {\n \n}" + }, + "contracts/vault/Vault.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../utils/TransferUtils.sol\";\nimport \"../utils/RoleKeys.sol\";\nimport \"../utils/Errors.sol\";\n\ncontract Vault is AccessControl {\n using SafeERC20 for IERC20;\n \n\n mapping(address => uint256) public tokenBalances;\n\n function transferOut(address token, address receiver, uint256 amount) external {\n if (receiver == address(this)) {\n revert Errors.AddressSelfNotSupported(receiver);\n }\n TransferUtils.transfer(token, receiver, amount);\n tokenBalances[token] = IERC20(token).balanceOf(address(this));\n }\n\n function getTransferInAmount(address token) external returns (uint256) {\n uint256 prevBalance = tokenBalances[token];\n uint256 nextBalance = IERC20(token).balanceOf(address(this));\n tokenBalances[token] = nextBalance;\n return nextBalance - prevBalance;\n }\n \n}\n" + }, + "hardhat/console.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nlibrary console {\n address constant CONSOLE_ADDRESS =\n 0x000000000000000000636F6e736F6c652e6c6f67;\n\n function _sendLogPayloadImplementation(bytes memory payload) internal view {\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n pop(\n staticcall(\n gas(),\n consoleAddress,\n add(payload, 32),\n mload(payload),\n 0,\n 0\n )\n )\n }\n }\n\n function _castToPure(\n function(bytes memory) internal view fnIn\n ) internal pure returns (function(bytes memory) pure fnOut) {\n assembly {\n fnOut := fnIn\n }\n }\n\n function _sendLogPayload(bytes memory payload) internal pure {\n _castToPure(_sendLogPayloadImplementation)(payload);\n }\n\n function log() internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n function logInt(int256 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function logUint(uint256 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function logString(string memory p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint256 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function log(string memory p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint256 p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n }\n\n function log(uint256 p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n }\n\n function log(uint256 p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n }\n\n function log(uint256 p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n }\n\n function log(string memory p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}\n" + } + }, + "settings": { + "viaIR": false, + "optimizer": { + "enabled": true, + "runs": 4294967295 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/apps/protocol/deployments/localhost/solcInputs/a5a4b4fb9b01e798eddcfdb1da63d0bc.json b/apps/protocol/deployments/localhost/solcInputs/a5a4b4fb9b01e798eddcfdb1da63d0bc.json new file mode 100644 index 000000000..048e55a9f --- /dev/null +++ b/apps/protocol/deployments/localhost/solcInputs/a5a4b4fb9b01e798eddcfdb1da63d0bc.json @@ -0,0 +1,67 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\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/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "contracts/interfaces/IDiamond.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\ninterface IDiamond {\n enum FacetCutAction {Add, Replace, Remove}\n // Add=0, Replace=1, Remove=2\n\n struct FacetCut {\n address facetAddress;\n FacetCutAction action;\n bytes4[] functionSelectors;\n }\n\n event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\n}" + }, + "contracts/interfaces/IDiamondCut.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\nimport { IDiamond } from \"./IDiamond.sol\";\n\ninterface IDiamondCut is IDiamond { \n\n /// @notice Add/replace/remove any number of functions and optionally execute\n /// a function with delegatecall\n /// @param _diamondCut Contains the facet addresses and function selectors\n /// @param _init The address of the contract or facet to execute _calldata\n /// @param _calldata A function call, including function selector and arguments\n /// _calldata is executed with delegatecall on _init\n function diamondCut(\n FacetCut[] calldata _diamondCut,\n address _init,\n bytes calldata _calldata\n ) external; \n}\n" + }, + "contracts/interfaces/IDiamondLoupe.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\n// A loupe is a small magnifying glass used to look at diamonds.\n// These functions look at diamonds\ninterface IDiamondLoupe {\n /// These functions are expected to be called frequently\n /// by tools.\n\n struct Facet {\n address facetAddress;\n bytes4[] functionSelectors;\n }\n\n /// @notice Gets all facet addresses and their four byte function selectors.\n /// @return facets_ Facet\n function facets() external view returns (Facet[] memory facets_);\n\n /// @notice Gets all the function selectors supported by a specific facet.\n /// @param _facet The facet address.\n /// @return facetFunctionSelectors_\n function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);\n\n /// @notice Get all the facet addresses used by a diamond.\n /// @return facetAddresses_\n function facetAddresses() external view returns (address[] memory facetAddresses_);\n\n /// @notice Gets the facet that supports the given selector.\n /// @dev If facet is not found return address(0).\n /// @param _functionSelector The function selector.\n /// @return facetAddress_ The facet address.\n function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);\n}\n" + }, + "contracts/router/Diamond.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n*\n* Implementation of a diamond.\n/******************************************************************************/\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { LibDiamond } from \"../storage/LibDiamond.sol\";\nimport { IDiamond } from \"../interfaces/IDiamond.sol\";\nimport { IDiamondCut } from \"../interfaces/IDiamondCut.sol\";\nimport { IDiamondLoupe } from \"../interfaces/IDiamondLoupe.sol\";\nimport \"../storage/RoleAccessControl.sol\";\nimport \"hardhat/console.sol\";\n\n// When no function exists for function called\nerror FunctionNotFound(bytes4 _functionSelector);\n\ncontract Diamond {\n constructor(address _diamondCutFacet, address _diamondLoupeFacet, address _init, address owner) payable {\n RoleAccessControl.grantRole(msg.sender, RoleAccessControl.ROLE_ADMIN);\n\n IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](2);\n bytes4[] memory functionSelectors = new bytes4[](1);\n functionSelectors[0] = IDiamondCut.diamondCut.selector;\n cut[0] = IDiamond.FacetCut({\n facetAddress: _diamondCutFacet,\n action: IDiamond.FacetCutAction.Add,\n functionSelectors: functionSelectors\n });\n\n bytes4[] memory loupeFunctionSelectors = new bytes4[](4);\n loupeFunctionSelectors[0] = IDiamondLoupe.facets.selector;\n loupeFunctionSelectors[1] = IDiamondLoupe.facetAddresses.selector;\n loupeFunctionSelectors[2] = IDiamondLoupe.facetAddress.selector;\n loupeFunctionSelectors[3] = IDiamondLoupe.facetFunctionSelectors.selector;\n cut[1] = IDiamond.FacetCut({\n facetAddress: _diamondLoupeFacet,\n action: IDiamond.FacetCutAction.Add,\n functionSelectors: loupeFunctionSelectors\n });\n LibDiamond.setContractOwner(owner);\n LibDiamond.diamondCut(cut, _init, abi.encodeWithSignature(\"init()\"));\n }\n\n // Find facet for function that is called and execute the\n // function if a facet is found and return any value.\n fallback() external payable {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n // get facet from function selector\n address facet = ds.facetAddressAndSelectorPosition[msg.sig].facetAddress;\n if (facet == address(0)) {\n revert FunctionNotFound(msg.sig);\n }\n // Execute external function from facet using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the facet\n let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/router/DiamondInit.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { LibDiamond } from \"../storage/LibDiamond.sol\";\nimport { IDiamondLoupe } from \"../interfaces/IDiamondLoupe.sol\";\nimport { IDiamondCut } from \"../interfaces/IDiamondCut.sol\";\n\ncontract DiamondInit {\n function init() external {\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\n ds.supportedInterfaces[type(IERC165).interfaceId] = true;\n ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;\n ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;\n }\n}\n" + }, + "contracts/storage/LibDiamond.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n/******************************************************************************\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\nimport { IDiamond } from \"../interfaces/IDiamond.sol\";\nimport { IDiamondCut } from \"../interfaces/IDiamondCut.sol\";\n\n// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.\n// The loupe functions are required by the EIP2535 Diamonds standard\n\nerror NoSelectorsGivenToAdd();\nerror NotContractOwner(address _user, address _contractOwner);\nerror NoSelectorsProvidedForFacetForCut(address _facetAddress);\nerror CannotAddSelectorsToZeroAddress(bytes4[] _selectors);\nerror NoBytecodeAtAddress(address _contractAddress, string _message);\nerror IncorrectFacetCutAction(uint8 _action);\nerror CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);\nerror CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);\nerror CannotReplaceImmutableFunction(bytes4 _selector);\nerror CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);\nerror CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);\nerror RemoveFacetAddressMustBeZeroAddress(address _facetAddress);\nerror CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);\nerror CannotRemoveImmutableFunction(bytes4 _selector);\nerror InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);\n\nlibrary LibDiamond {\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\"diamond.standard.diamond.storage\");\n\n struct FacetAddressAndSelectorPosition {\n address facetAddress;\n uint16 selectorPosition;\n }\n\n struct DiamondStorage {\n // function selector => facet address and selector position in selectors array\n mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;\n bytes4[] selectors;\n mapping(bytes4 => bool) supportedInterfaces;\n address contractOwner;\n }\n\n function diamondStorage() internal pure returns (DiamondStorage storage ds) {\n bytes32 position = DIAMOND_STORAGE_POSITION;\n assembly {\n ds.slot := position\n }\n }\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n function setContractOwner(address _newOwner) internal {\n DiamondStorage storage ds = diamondStorage();\n address previousOwner = ds.contractOwner;\n ds.contractOwner = _newOwner;\n emit OwnershipTransferred(previousOwner, _newOwner);\n }\n\n function contractOwner() internal view returns (address contractOwner_) {\n contractOwner_ = diamondStorage().contractOwner;\n }\n\n function enforceIsContractOwner() internal view {\n if (msg.sender != diamondStorage().contractOwner) {\n revert NotContractOwner(msg.sender, diamondStorage().contractOwner);\n }\n }\n\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);\n\n // Internal function version of diamondCut\n function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {\n for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\n bytes4[] memory functionSelectors = _diamondCut[facetIndex].functionSelectors;\n address facetAddress = _diamondCut[facetIndex].facetAddress;\n if (functionSelectors.length == 0) {\n revert NoSelectorsProvidedForFacetForCut(facetAddress);\n }\n IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;\n if (action == IDiamond.FacetCutAction.Add) {\n addFunctions(facetAddress, functionSelectors);\n } else if (action == IDiamond.FacetCutAction.Replace) {\n replaceFunctions(facetAddress, functionSelectors);\n } else if (action == IDiamond.FacetCutAction.Remove) {\n removeFunctions(facetAddress, functionSelectors);\n } else {\n revert IncorrectFacetCutAction(uint8(action));\n }\n }\n emit DiamondCut(_diamondCut, _init, _calldata);\n initializeDiamondCut(_init, _calldata);\n }\n\n function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\n if (_facetAddress == address(0)) {\n revert CannotAddSelectorsToZeroAddress(_functionSelectors);\n }\n DiamondStorage storage ds = diamondStorage();\n uint16 selectorCount = uint16(ds.selectors.length);\n enforceHasContractCode(_facetAddress, \"LibDiamondCut: Add facet has no code\");\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\n bytes4 selector = _functionSelectors[selectorIndex];\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\n if (oldFacetAddress != address(0)) {\n revert CannotAddFunctionToDiamondThatAlreadyExists(selector);\n }\n ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(\n _facetAddress,\n selectorCount\n );\n ds.selectors.push(selector);\n selectorCount++;\n }\n }\n\n function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\n DiamondStorage storage ds = diamondStorage();\n if (_facetAddress == address(0)) {\n revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);\n }\n enforceHasContractCode(_facetAddress, \"LibDiamondCut: Replace facet has no code\");\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\n bytes4 selector = _functionSelectors[selectorIndex];\n address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;\n // can't replace immutable functions -- functions defined directly in the diamond in this case\n if (oldFacetAddress == address(this)) {\n revert CannotReplaceImmutableFunction(selector);\n }\n if (oldFacetAddress == _facetAddress) {\n revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);\n }\n if (oldFacetAddress == address(0)) {\n revert CannotReplaceFunctionThatDoesNotExists(selector);\n }\n // replace old facet address\n ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress;\n }\n }\n\n function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {\n DiamondStorage storage ds = diamondStorage();\n uint256 selectorCount = ds.selectors.length;\n if (_facetAddress != address(0)) {\n revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);\n }\n for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) {\n bytes4 selector = _functionSelectors[selectorIndex];\n FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds\n .facetAddressAndSelectorPosition[selector];\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {\n revert CannotRemoveFunctionThatDoesNotExist(selector);\n }\n\n // can't remove immutable functions -- functions defined directly in the diamond\n if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {\n revert CannotRemoveImmutableFunction(selector);\n }\n // replace selector with last selector\n selectorCount--;\n if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {\n bytes4 lastSelector = ds.selectors[selectorCount];\n ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;\n ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition\n .selectorPosition;\n }\n // delete last selector\n ds.selectors.pop();\n delete ds.facetAddressAndSelectorPosition[selector];\n }\n }\n\n function initializeDiamondCut(address _init, bytes memory _calldata) internal {\n if (_init == address(0)) {\n return;\n }\n enforceHasContractCode(_init, \"LibDiamondCut: _init address has no code\");\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\n if (!success) {\n if (error.length > 0) {\n // bubble up error\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(error)\n revert(add(32, error), returndata_size)\n }\n } else {\n revert InitializationFunctionReverted(_init, _calldata);\n }\n }\n }\n\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\n uint256 contractSize;\n assembly {\n contractSize := extcodesize(_contract)\n }\n if (contractSize == 0) {\n revert NoBytecodeAtAddress(_contract, _errorMessage);\n }\n }\n}\n" + }, + "contracts/storage/RoleAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"../utils/Errors.sol\";\n\nlibrary RoleAccessControl {\n using EnumerableSet for EnumerableSet.Bytes32Set;\n\n bytes32 internal constant ACCESS_CONTROL_KEY = keccak256(abi.encode(\"link.profile.storage.AccessControl\"));\n\n bytes32 constant ROLE_ADMIN = \"ADMIN\";\n bytes32 constant ROLE_CONFIG = \"CONFIG\";\n bytes32 constant ROLE_KEEPER = \"KEEPER\";\n\n struct Props {\n mapping(address => EnumerableSet.Bytes32Set) accountRoles;\n }\n\n function load() public pure returns (Props storage self) {\n bytes32 s = ACCESS_CONTROL_KEY;\n assembly {\n self.slot := s\n }\n }\n\n function checkRole(bytes32 role) internal view {\n if (!hasRole(msg.sender, role)) {\n revert Errors.InvalidRoleAccess(msg.sender, role);\n }\n }\n\n function hasRole(bytes32 role) internal view returns (bool) {\n return hasRole(msg.sender, role);\n }\n\n function hasRole(address account, bytes32 role) internal view returns (bool) {\n Props storage self = load();\n return self.accountRoles[account].contains(role);\n }\n\n function grantRole(address account, bytes32 role) internal {\n Props storage self = load();\n self.accountRoles[account].add(role);\n }\n\n function revokeRole(address account, bytes32 role) internal {\n Props storage self = load();\n if (self.accountRoles[account].contains(role)) {\n self.accountRoles[account].remove(role);\n }\n }\n\n function revokeAllRole(address account) internal {\n Props storage self = load();\n delete self.accountRoles[account];\n }\n}\n" + }, + "contracts/utils/Errors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary Errors {\n // common\n error AddressSelfNotSupported(address self);\n error UnknownError(bytes msg);\n error BlockNumberInvalid();\n error InvalidRoleAccess(address account, bytes32 role);\n\n // account\n error AccountNotExist();\n}\n" + }, + "contracts/utils/RoleKeys.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary RoleKeys {\n bytes32 public constant ADMIN_ROLE = keccak256(\"ADMIN_ROLE\");\n\n bytes32 public constant CONFIG_ROLE = keccak256(\"CONFIG_ROLE\");\n}\n" + }, + "hardhat/console.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nlibrary console {\n address constant CONSOLE_ADDRESS =\n 0x000000000000000000636F6e736F6c652e6c6f67;\n\n function _sendLogPayloadImplementation(bytes memory payload) internal view {\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n pop(\n staticcall(\n gas(),\n consoleAddress,\n add(payload, 32),\n mload(payload),\n 0,\n 0\n )\n )\n }\n }\n\n function _castToPure(\n function(bytes memory) internal view fnIn\n ) internal pure returns (function(bytes memory) pure fnOut) {\n assembly {\n fnOut := fnIn\n }\n }\n\n function _sendLogPayload(bytes memory payload) internal pure {\n _castToPure(_sendLogPayloadImplementation)(payload);\n }\n\n function log() internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n function logInt(int256 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function logUint(uint256 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function logString(string memory p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint256 p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function log(string memory p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint256 p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n }\n\n function log(uint256 p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n }\n\n function log(uint256 p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n }\n\n function log(uint256 p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n }\n\n function log(string memory p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint256 p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint256 p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint256 p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal pure {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}\n" + } + }, + "settings": { + "viaIR": false, + "optimizer": { + "enabled": true, + "runs": 4294967295 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/apps/protocol/ecosystem.config.js b/apps/protocol/ecosystem.config.js new file mode 100644 index 000000000..e33ff3be5 --- /dev/null +++ b/apps/protocol/ecosystem.config.js @@ -0,0 +1,14 @@ +module.exports = { + apps: [ + { + name: 'hardhat-development', + script: './node_modules/.bin/hardhat', + args: 'node --hostname 10.0.4.9', + // args: 'node', + watch: false, + instance: 1, + log_date_format: 'YYYY-MM-DD HH:mm:ss', + exec_mode: 'cluster', + }, + ], +} diff --git a/apps/protocol/hardhat.config.ts b/apps/protocol/hardhat.config.ts new file mode 100644 index 000000000..bf5b6814f --- /dev/null +++ b/apps/protocol/hardhat.config.ts @@ -0,0 +1,73 @@ +import 'tsconfig-paths/register' +import { resolve } from 'path' +import { HardhatUserConfig } from 'hardhat/config' +import { config as dotenvConfig } from 'dotenv' +import '@nomicfoundation/hardhat-chai-matchers' +import '@nomicfoundation/hardhat-toolbox' +import '@nomicfoundation/hardhat-ethers' +import 'hardhat-deploy' +import 'hardhat-gas-reporter' +import 'hardhat-deploy-ethers' + +import '@typechain/hardhat' + +const dotenvConfigPath: string = './.env' +dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) }) + +const config: HardhatUserConfig = { + defaultNetwork: 'hardhat', + namedAccounts: { + deployer: 0, + }, + + gasReporter: { + enabled: false, + }, + + networks: { + hardhat: { + saveDeployments: true, + allowUnlimitedContractSize: true, + // forking: { + // url: "https://mainnet.chainnodes.org/8fe75768-846a-427a-8651-b5c1adf9a1f1", + // }, + chainId: 31337, + }, + localhost: { + saveDeployments: false, + }, + }, + + solidity: { + compilers: [ + { + version: '0.8.18', + settings: { + viaIR: false, + optimizer: { + enabled: true, + runs: 4_294_967_295, + }, + }, + }, + ], + }, + + paths: { + artifacts: './artifacts', + cache: './cache', + sources: './contracts', + tests: './test', + }, + + typechain: { + outDir: 'types', + target: 'ethers-v6', + }, + + mocha: { + timeout: 1000000, + }, +} + +export default config diff --git a/apps/protocol/index.d.ts b/apps/protocol/index.d.ts new file mode 100644 index 000000000..7dc6f385c --- /dev/null +++ b/apps/protocol/index.d.ts @@ -0,0 +1 @@ +declare module 'tsconfig-paths/register' {} diff --git a/apps/protocol/package.json b/apps/protocol/package.json new file mode 100644 index 000000000..96be99213 --- /dev/null +++ b/apps/protocol/package.json @@ -0,0 +1,63 @@ +{ + "name": "protocol", + "scripts": { + "hardhat:development": "pm2 restart ecosystem.config.js --only hardhat-development", + "compile": "hardhat compile", + "deploy": "pnpm run compile && hardhat deploy", + "node": "hardhat node", + "test:generate": "tsx utils/test-deployment-generator.ts", + "test": "hardhat test --deploy-fixture", + "gen:address": "hardhat run scripts/generate-contract-address.ts", + "gen:abi": "wagmi generate", + "cov": "hardhat coverage", + "export": "hardhat export", + "typechain": "hardhat typechain", + "postinstall": "pnpm typechain", + "clean": "rimraf ./artifacts ./cache ./coverage ./types ./coverage.json && pnpm run typechain" + }, + "devDependencies": { + "@nomicfoundation/hardhat-chai-matchers": "^2.0.1", + "@nomicfoundation/hardhat-ethers": "^3.0.4", + "@nomicfoundation/hardhat-network-helpers": "^1.0.8", + "@nomicfoundation/hardhat-verify": "^1.0.4", + "@typechain/ethers-v6": "^0.4.0", + "@typechain/hardhat": "^8.0.0", + "@types/chai": "^4.3.5", + "@types/lodash": "^4.14.198", + "@types/mocha": "^10.0.1", + "@types/node": "^20.4.5", + "dotenv": "^16.3.1", + "ethers": "^6.6.4", + "fs-jetpack": "^5.1.0", + "hardhat-gas-reporter": "^1.0.9", + "mathjs": "^11.9.1", + "pm2": "^5.3.0", + "prettier": "^3.0.0", + "prettier-plugin-solidity": "^1.1.3", + "rimraf": "^4.1.2", + "solidity-coverage": "^0.8.2", + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.2.0", + "tsx": "^3.12.7", + "typechain": "^8.2.0", + "typescript": "^5.1.6", + "viem": "^1.4.2" + }, + "dependencies": { + "@chainlink/contracts": "^0.6.1", + "@nomicfoundation/hardhat-toolbox": "^3.0.0", + "@openzeppelin/contracts": "^4.9.2", + "@types/ethereumjs-abi": "^0.6.5", + "@uniswap/hardhat-v3-deploy": "^0.1.1", + "@uniswap/v3-core": "^1.0.1", + "@uniswap/v3-periphery": "^1.4.4", + "@wagmi/cli": "^1.3.0", + "cross-env": "^7.0.3", + "ethereumjs-abi": "^0.6.8", + "hardhat": "^2.17.0", + "hardhat-deploy": "^0.11.34", + "hardhat-deploy-ethers": "^0.4.1", + "lodash": "^4.17.21", + "mocha": "^10.2.0" + } +} diff --git a/apps/protocol/remix-compiler.config.js b/apps/protocol/remix-compiler.config.js new file mode 100644 index 000000000..013130857 --- /dev/null +++ b/apps/protocol/remix-compiler.config.js @@ -0,0 +1,16 @@ +module.exports = { + solidity: { + version: '0.8.18', + settings: { + viaIR: true, + optimizer: { + enabled: true, + details: { + yulDetails: { + optimizerSteps: 'u', + }, + }, + }, + }, + }, +} diff --git a/apps/protocol/scripts/generate-contract-address.ts b/apps/protocol/scripts/generate-contract-address.ts new file mode 100644 index 000000000..4e0c98a7a --- /dev/null +++ b/apps/protocol/scripts/generate-contract-address.ts @@ -0,0 +1,22 @@ +import jetpack from 'fs-jetpack' +import { join } from 'path' + +const cwd = process.cwd() +const files = jetpack.find(join(cwd, 'deployments', 'localhost'), { matching: '*.json' }) + +const addressMap = files.reduce>((acc, file) => { + const json = jetpack.read(file, 'json') + if (json?.address) { + const [, name] = file.match(/.*\/(.*)\.json$/) || [] + if (name) acc[name] = json.address + } + return acc +}, {}) + +jetpack.write( + join(cwd, 'abi', 'address.ts'), + ` + export const json = ${JSON.stringify(addressMap, null, 2)} + export const addressMap: Record = json + `, +) diff --git a/apps/protocol/tsconfig.json b/apps/protocol/tsconfig.json new file mode 100644 index 000000000..d7199c411 --- /dev/null +++ b/apps/protocol/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "declaration": true, + "declarationMap": true, + "emitDecoratorMetadata": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es2020"], + "module": "commonjs", + "moduleResolution": "node", + "noImplicitAny": true, + "removeComments": true, + "resolveJsonModule": true, + "sourceMap": true, + "strict": true, + "target": "es2020", + "paths": { + "@utils/*": ["./utils/*"], + "@abi/*": ["./abi/*"], + "@test/*": ["./test/*"] + } + }, + + "include": [ + "hardhat.config.ts", + "./scripts", + "./utils", + "./deploy", + "./abi", + "./test", + "typechain/**/*", + "wagmi.config.ts", + "index.d.ts" + ] +} diff --git a/apps/protocol/utils/deploy.ts b/apps/protocol/utils/deploy.ts new file mode 100644 index 000000000..94b34309d --- /dev/null +++ b/apps/protocol/utils/deploy.ts @@ -0,0 +1,126 @@ +import { ethers } from 'hardhat' +import { + Address, + DeployFunction, + DeployOptionsBase, + DeployResult, + Deployment, + DeploymentsExtension, +} from 'hardhat-deploy/types' +import { HardhatRuntimeEnvironment } from 'hardhat/types' + +type LibraryName = 'PermissionFlag' | 'LibDiamond' + +type ContractName = LibraryName | 'Multicall3' | 'DiamondCutFacet' + +type DependencyContracts = Record + +type AfterDeployArgs = { + deployedContract: DeployResult + deployer: string + getNamedAccounts: () => Promise> + deployments: DeploymentsExtension +} + +type GetDeployArgs = ({ + dependencyContracts, +}: { + dependencyContracts: DependencyContracts +}) => Promise | DeployOptionsBase['args'] + +export type DeployFunctionOptions = { + contractName: ContractName + dependencyNames?: ContractName[] + getDeployArgs?: GetDeployArgs + libraryNames?: LibraryName[] + id?: string + afterDeploy?: (args: AfterDeployArgs) => Promise +} + +export function createDeployFunction(options: DeployFunctionOptions) { + const { contractName, dependencyNames, getDeployArgs, libraryNames, afterDeploy } = options + + const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { + const { getNamedAccounts, deployments } = hre + const { deploy, get } = deployments + const { deployer } = await getNamedAccounts() + const libraries = await getLibraries(hre.deployments, libraryNames) + const args = await getArgs(hre.deployments, options) + + let deployedContract + + try { + deployedContract = await deploy(contractName, { + from: deployer, + log: true, + args: args, + libraries, + }) + } catch (e) { + // console.error("Deploy error", e); + + // the caught error might not be very informative + // e.g. if some library dependency is missing, which library it is + // is not shown in the error + // attempt a deploy using hardhat so that a more detailed error + // would be thrown + await deployContract(contractName, args, { + libraries, + }) + + // throw an error even if the hardhat deploy works + // because the actual deploy did not succeed + throw new Error(`Deploy failed with error ${e}`) + } + + if (afterDeploy) { + await afterDeploy({ deployedContract, deployer, getNamedAccounts, deployments }) + } + } + + func.id = options.id || contractName // id required to prevent reexecution + func.tags = [contractName] + func.dependencies = getDependencies(options) + + return func +} + +async function getArgs(deployments: DeploymentsExtension, options: DeployFunctionOptions) { + const { dependencyNames = [], getDeployArgs } = options + const dependencyContracts = {} as DependencyContracts + + if (dependencyNames) { + for (let i = 0; i < dependencyNames.length; i++) {} + } + + for (const dependencyName of dependencyNames) { + dependencyContracts[dependencyName] = await deployments.get(dependencyName) + } + + let args: DeployOptionsBase['args'] = [] + + if (getDeployArgs) { + args = (await getDeployArgs({ dependencyContracts }))! + } + return args +} + +async function getLibraries(deployments: DeploymentsExtension, libraryNames: string[] = []) { + const libraries: Record = {} + + for (const libraryName of libraryNames) { + libraries[libraryName] = (await deployments.get(libraryName)).address + } + + return libraries +} + +function getDependencies(options: DeployFunctionOptions) { + const { dependencyNames = [], libraryNames = [] } = options + return [...dependencyNames, ...libraryNames] +} + +async function deployContract(name: string, args: any, contractOptions = {}) { + const contractFactory = await ethers.getContractFactory(name, contractOptions) + return contractFactory.deploy(...args) +} diff --git a/apps/protocol/utils/diamond.ts b/apps/protocol/utils/diamond.ts new file mode 100644 index 000000000..251fc721a --- /dev/null +++ b/apps/protocol/utils/diamond.ts @@ -0,0 +1,58 @@ +import { BaseContract } from 'ethers' +import { ethers } from 'hardhat' + +export const FacetCutAction = { Add: 0, Replace: 1, Remove: 2 } + +export function getSelectors(contract: BaseContract) { + const selectors: String[] = [] + contract.interface.forEachFunction((interfaceFunction) => { + if ('constructor' != interfaceFunction.name && 'supportsInterface(bytes4)' != interfaceFunction.name) { + selectors.push(interfaceFunction.selector) + console.log('add interfaceFunction.name', interfaceFunction.name, interfaceFunction.selector) + } + }) + return selectors +} + +export function getSelectorsExcludeAlready(contract: BaseContract, alreadySelectors: String[]) { + const selectors: String[] = [] + contract.interface.forEachFunction((interfaceFunction) => { + if ( + 'constructor' != interfaceFunction.name && + 'supportsInterface(bytes4)' != interfaceFunction.name && + !alreadySelectors.includes(interfaceFunction.selector) + ) { + selectors.push(interfaceFunction.selector) + console.log('add interfaceFunction.name', interfaceFunction.name, interfaceFunction.selector) + } + }) + return selectors +} + +export function getSelectorsIncludeAlready(contract: BaseContract, alreadySelectors: String[]) { + const selectors: String[] = [] + contract.interface.forEachFunction((interfaceFunction) => { + if (alreadySelectors.includes(interfaceFunction.selector)) { + selectors.push(interfaceFunction.selector) + console.log('delete interfaceFunction.name', interfaceFunction.name, interfaceFunction.selector) + } + }) + return selectors +} + +export async function getAllAlreadySelectors(diamondAddr: string) { + let selectors: String[] = [] + const diamondLoupeFacet = await ethers.getContractAt('DiamondLoupeFacet', diamondAddr) + const alreadyFacets = await diamondLoupeFacet.facets() + + console.log('alreadyFacets', alreadyFacets) + + for (var i = 0; i < alreadyFacets.length; i++) { + selectors = selectors.concat(alreadyFacets[i].functionSelectors) + } + return selectors +} + +exports.getSelectors = getSelectors +exports.getAllAlreadySelectors = getAllAlreadySelectors +exports.FacetCutAction = FacetCutAction diff --git a/apps/protocol/wagmi.config.ts b/apps/protocol/wagmi.config.ts new file mode 100644 index 000000000..3303f8f74 --- /dev/null +++ b/apps/protocol/wagmi.config.ts @@ -0,0 +1,19 @@ +import { defineConfig, loadEnv } from '@wagmi/cli' +import { react, actions, hardhat, etherscan } from '@wagmi/cli/plugins' + +export default defineConfig(() => { + const env = loadEnv({ + mode: process.env.NODE_ENV, + envDir: process.cwd(), + }) + + return { + out: 'abi/generated.ts', + contracts: [], + plugins: [ + hardhat({ + project: './', + }), + ], + } +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c559dbeff..bf7bd725b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true @@ -577,6 +577,133 @@ importers: specifier: 5.2.2 version: 5.2.2 + apps/protocol: + dependencies: + '@chainlink/contracts': + specifier: ^0.6.1 + version: 0.6.1(ethers@6.10.0) + '@nomicfoundation/hardhat-toolbox': + specifier: ^3.0.0 + version: 3.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.3)(@nomicfoundation/hardhat-ethers@3.0.5)(@nomicfoundation/hardhat-network-helpers@1.0.10)(@nomicfoundation/hardhat-verify@1.1.1)(@typechain/ethers-v6@0.4.3)(@typechain/hardhat@8.0.3)(@types/chai@4.3.11)(@types/mocha@10.0.6)(@types/node@20.10.6)(chai@4.4.1)(ethers@6.10.0)(hardhat-gas-reporter@1.0.9)(hardhat@2.19.4)(solidity-coverage@0.8.5)(ts-node@10.9.2)(typechain@8.3.2)(typescript@5.3.3) + '@openzeppelin/contracts': + specifier: ^4.9.2 + version: 4.9.5 + '@types/ethereumjs-abi': + specifier: ^0.6.5 + version: 0.6.5 + '@uniswap/hardhat-v3-deploy': + specifier: ^0.1.1 + version: 0.1.1(hardhat@2.19.4) + '@uniswap/v3-core': + specifier: ^1.0.1 + version: 1.0.1 + '@uniswap/v3-periphery': + specifier: ^1.4.4 + version: 1.4.4 + '@wagmi/cli': + specifier: ^1.3.0 + version: 1.5.2(typescript@5.3.3) + cross-env: + specifier: ^7.0.3 + version: 7.0.3 + ethereumjs-abi: + specifier: ^0.6.8 + version: 0.6.8 + hardhat: + specifier: ^2.17.0 + version: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + hardhat-deploy: + specifier: ^0.11.34 + version: 0.11.45 + hardhat-deploy-ethers: + specifier: ^0.4.1 + version: 0.4.1(@nomicfoundation/hardhat-ethers@3.0.5)(hardhat-deploy@0.11.45)(hardhat@2.19.4) + lodash: + specifier: ^4.17.21 + version: 4.17.21 + mocha: + specifier: ^10.2.0 + version: 10.2.0 + devDependencies: + '@nomicfoundation/hardhat-chai-matchers': + specifier: ^2.0.1 + version: 2.0.3(@nomicfoundation/hardhat-ethers@3.0.5)(chai@4.4.1)(ethers@6.10.0)(hardhat@2.19.4) + '@nomicfoundation/hardhat-ethers': + specifier: ^3.0.4 + version: 3.0.5(ethers@6.10.0)(hardhat@2.19.4) + '@nomicfoundation/hardhat-network-helpers': + specifier: ^1.0.8 + version: 1.0.10(hardhat@2.19.4) + '@nomicfoundation/hardhat-verify': + specifier: ^1.0.4 + version: 1.1.1(hardhat@2.19.4) + '@typechain/ethers-v6': + specifier: ^0.4.0 + version: 0.4.3(ethers@6.10.0)(typechain@8.3.2)(typescript@5.3.3) + '@typechain/hardhat': + specifier: ^8.0.0 + version: 8.0.3(@typechain/ethers-v6@0.4.3)(ethers@6.10.0)(hardhat@2.19.4)(typechain@8.3.2) + '@types/chai': + specifier: ^4.3.5 + version: 4.3.11 + '@types/lodash': + specifier: ^4.14.198 + version: 4.14.202 + '@types/mocha': + specifier: ^10.0.1 + version: 10.0.6 + '@types/node': + specifier: ^20.4.5 + version: 20.10.6 + dotenv: + specifier: ^16.3.1 + version: 16.3.2 + ethers: + specifier: ^6.6.4 + version: 6.10.0 + fs-jetpack: + specifier: ^5.1.0 + version: 5.1.0 + hardhat-gas-reporter: + specifier: ^1.0.9 + version: 1.0.9(hardhat@2.19.4) + mathjs: + specifier: ^11.9.1 + version: 11.12.0 + pm2: + specifier: ^5.3.0 + version: 5.3.1 + prettier: + specifier: ^3.0.0 + version: 3.1.0 + prettier-plugin-solidity: + specifier: ^1.1.3 + version: 1.3.1(prettier@3.1.0) + rimraf: + specifier: ^4.1.2 + version: 4.4.1 + solidity-coverage: + specifier: ^0.8.2 + version: 0.8.5(hardhat@2.19.4) + ts-node: + specifier: ^10.9.1 + version: 10.9.2(@types/node@20.10.6)(typescript@5.3.3) + tsconfig-paths: + specifier: ^4.2.0 + version: 4.2.0 + tsx: + specifier: ^3.12.7 + version: 3.14.0 + typechain: + specifier: ^8.2.0 + version: 8.3.2(typescript@5.3.3) + typescript: + specifier: ^5.1.6 + version: 5.3.3 + viem: + specifier: ^1.4.2 + version: 1.19.11(typescript@5.3.3)(zod@3.22.4) + apps/web: dependencies: '@dnd-kit/core': @@ -5251,7 +5378,6 @@ packages: /@adraffy/ens-normalize@1.10.0: resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} - dev: false /@ampproject/remapping@2.2.1: resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==} @@ -5306,7 +5432,7 @@ packages: '@babel/traverse': 7.23.7 '@babel/types': 7.23.6 convert-source-map: 2.0.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -5380,7 +5506,7 @@ packages: '@babel/core': 7.23.5 '@babel/helper-compilation-targets': 7.23.6 '@babel/helper-plugin-utils': 7.22.5 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -5394,7 +5520,7 @@ packages: '@babel/core': 7.23.5 '@babel/helper-compilation-targets': 7.23.6 '@babel/helper-plugin-utils': 7.22.5 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -6474,7 +6600,7 @@ packages: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.23.6 '@babel/types': 7.23.6 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -6491,6 +6617,45 @@ packages: resolution: {integrity: sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==} dev: false + /@chainlink/contracts@0.6.1(ethers@6.10.0): + resolution: {integrity: sha512-EuwijGexttw0UjfrW+HygwhQIrGAbqpf1ue28R55HhWMHBzphEH0PhWm8DQmFfj5OZNy8Io66N4L0nStkZ3QKQ==} + dependencies: + '@eth-optimism/contracts': 0.5.40(ethers@6.10.0) + '@openzeppelin/contracts': 4.3.3 + '@openzeppelin/contracts-upgradeable': 4.9.5 + '@openzeppelin/contracts-v0.7': /@openzeppelin/contracts@3.4.2 + transitivePeerDependencies: + - bufferutil + - ethers + - utf-8-validate + dev: false + + /@chainsafe/as-sha256@0.3.1: + resolution: {integrity: sha512-hldFFYuf49ed7DAakWVXSJODuq3pzJEguD8tQ7h+sGkM18vja+OFoJI9krnGmgzyuZC2ETX0NOIcCTy31v2Mtg==} + + /@chainsafe/persistent-merkle-tree@0.4.2: + resolution: {integrity: sha512-lLO3ihKPngXLTus/L7WHKaw9PnNJWizlOF1H9NNzHP6Xvh82vzg9F2bzkXhYIFshMZ2gTCEz8tq6STe7r5NDfQ==} + dependencies: + '@chainsafe/as-sha256': 0.3.1 + + /@chainsafe/persistent-merkle-tree@0.5.0: + resolution: {integrity: sha512-l0V1b5clxA3iwQLXP40zYjyZYospQLZXzBVIhhr9kDg/1qHZfzzHw0jj4VPBijfYCArZDlPkRi1wZaV2POKeuw==} + dependencies: + '@chainsafe/as-sha256': 0.3.1 + + /@chainsafe/ssz@0.10.2: + resolution: {integrity: sha512-/NL3Lh8K+0q7A3LsiFq09YXS9fPE+ead2rr7vM2QK8PLzrNsw3uqrif9bpRX5UxgeRjM+vYi+boCM3+GM4ovXg==} + dependencies: + '@chainsafe/as-sha256': 0.3.1 + '@chainsafe/persistent-merkle-tree': 0.5.0 + + /@chainsafe/ssz@0.9.4: + resolution: {integrity: sha512-77Qtg2N1ayqs4Bg/wvnWfg5Bta7iy7IRh8XqXh7oNMeP2HBbBwx8m6yTpA8p0EHItWPEBkgZd5S5/LSlp3GXuQ==} + dependencies: + '@chainsafe/as-sha256': 0.3.1 + '@chainsafe/persistent-merkle-tree': 0.4.2 + case: 1.6.3 + /@changesets/apply-release-plan@6.1.4: resolution: {integrity: sha512-FMpKF1fRlJyCZVYHr3CbinpZZ+6MwvOtWUuO8uo+svcATEoc1zRDcj23pAurJ2TZ/uVz1wFHH6K3NlACy0PLew==} dependencies: @@ -6703,6 +6868,13 @@ packages: - utf-8-validate dev: false + /@colors/colors@1.5.0: + resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} + engines: {node: '>=0.1.90'} + requiresBuild: true + dev: false + optional: true + /@commitlint/cli@17.8.1: resolution: {integrity: sha512-ay+WbzQesE0Rv4EQKfNbSMiJJ12KdKTDzIt0tcK4k11FdsWmtwP0Kp1NWMOUswfIWo6Eb7p7Ln721Nx9FLNBjg==} engines: {node: '>=v14'} @@ -6970,6 +7142,15 @@ packages: resolution: {integrity: sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==} dev: false + /@esbuild/android-arm64@0.16.17: + resolution: {integrity: sha512-MIGl6p5sc3RDTLLkYL1MyL8BMRN4tLMRCn+yRJJmEDvYZ2M7tmAf80hx1kbNEUX2KJ50RRtxZ4JHLvCfuB6kBg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: false + optional: true + /@esbuild/android-arm64@0.18.20: resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} engines: {node: '>=12'} @@ -6978,6 +7159,15 @@ packages: requiresBuild: true optional: true + /@esbuild/android-arm@0.16.17: + resolution: {integrity: sha512-N9x1CMXVhtWEAMS7pNNONyA14f71VPQN9Cnavj1XQh6T7bskqiLLrSca4O0Vr8Wdcga943eThxnVp3JLnBMYtw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: false + optional: true + /@esbuild/android-arm@0.18.20: resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} engines: {node: '>=12'} @@ -6986,6 +7176,15 @@ packages: requiresBuild: true optional: true + /@esbuild/android-x64@0.16.17: + resolution: {integrity: sha512-a3kTv3m0Ghh4z1DaFEuEDfz3OLONKuFvI4Xqczqx4BqLyuFaFkuaG4j2MtA6fuWEFeC5x9IvqnX7drmRq/fyAQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: false + optional: true + /@esbuild/android-x64@0.18.20: resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} engines: {node: '>=12'} @@ -6994,6 +7193,15 @@ packages: requiresBuild: true optional: true + /@esbuild/darwin-arm64@0.16.17: + resolution: {integrity: sha512-/2agbUEfmxWHi9ARTX6OQ/KgXnOWfsNlTeLcoV7HSuSTv63E4DqtAc+2XqGw1KHxKMHGZgbVCZge7HXWX9Vn+w==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + /@esbuild/darwin-arm64@0.18.20: resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} engines: {node: '>=12'} @@ -7002,6 +7210,15 @@ packages: requiresBuild: true optional: true + /@esbuild/darwin-x64@0.16.17: + resolution: {integrity: sha512-2By45OBHulkd9Svy5IOCZt376Aa2oOkiE9QWUK9fe6Tb+WDr8hXL3dpqi+DeLiMed8tVXspzsTAvd0jUl96wmg==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + /@esbuild/darwin-x64@0.18.20: resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} engines: {node: '>=12'} @@ -7010,6 +7227,15 @@ packages: requiresBuild: true optional: true + /@esbuild/freebsd-arm64@0.16.17: + resolution: {integrity: sha512-mt+cxZe1tVx489VTb4mBAOo2aKSnJ33L9fr25JXpqQqzbUIw/yzIzi+NHwAXK2qYV1lEFp4OoVeThGjUbmWmdw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: false + optional: true + /@esbuild/freebsd-arm64@0.18.20: resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} engines: {node: '>=12'} @@ -7018,6 +7244,15 @@ packages: requiresBuild: true optional: true + /@esbuild/freebsd-x64@0.16.17: + resolution: {integrity: sha512-8ScTdNJl5idAKjH8zGAsN7RuWcyHG3BAvMNpKOBaqqR7EbUhhVHOqXRdL7oZvz8WNHL2pr5+eIT5c65kA6NHug==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: false + optional: true + /@esbuild/freebsd-x64@0.18.20: resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} engines: {node: '>=12'} @@ -7026,6 +7261,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-arm64@0.16.17: + resolution: {integrity: sha512-7S8gJnSlqKGVJunnMCrXHU9Q8Q/tQIxk/xL8BqAP64wchPCTzuM6W3Ra8cIa1HIflAvDnNOt2jaL17vaW+1V0g==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-arm64@0.18.20: resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} engines: {node: '>=12'} @@ -7034,6 +7278,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-arm@0.16.17: + resolution: {integrity: sha512-iihzrWbD4gIT7j3caMzKb/RsFFHCwqqbrbH9SqUSRrdXkXaygSZCZg1FybsZz57Ju7N/SHEgPyaR0LZ8Zbe9gQ==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-arm@0.18.20: resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} engines: {node: '>=12'} @@ -7042,6 +7295,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-ia32@0.16.17: + resolution: {integrity: sha512-kiX69+wcPAdgl3Lonh1VI7MBr16nktEvOfViszBSxygRQqSpzv7BffMKRPMFwzeJGPxcio0pdD3kYQGpqQ2SSg==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-ia32@0.18.20: resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} engines: {node: '>=12'} @@ -7050,6 +7312,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-loong64@0.16.17: + resolution: {integrity: sha512-dTzNnQwembNDhd654cA4QhbS9uDdXC3TKqMJjgOWsC0yNCbpzfWoXdZvp0mY7HU6nzk5E0zpRGGx3qoQg8T2DQ==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-loong64@0.18.20: resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} engines: {node: '>=12'} @@ -7058,6 +7329,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-mips64el@0.16.17: + resolution: {integrity: sha512-ezbDkp2nDl0PfIUn0CsQ30kxfcLTlcx4Foz2kYv8qdC6ia2oX5Q3E/8m6lq84Dj/6b0FrkgD582fJMIfHhJfSw==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-mips64el@0.18.20: resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} engines: {node: '>=12'} @@ -7066,6 +7346,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-ppc64@0.16.17: + resolution: {integrity: sha512-dzS678gYD1lJsW73zrFhDApLVdM3cUF2MvAa1D8K8KtcSKdLBPP4zZSLy6LFZ0jYqQdQ29bjAHJDgz0rVbLB3g==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-ppc64@0.18.20: resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} engines: {node: '>=12'} @@ -7074,6 +7363,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-riscv64@0.16.17: + resolution: {integrity: sha512-ylNlVsxuFjZK8DQtNUwiMskh6nT0vI7kYl/4fZgV1llP5d6+HIeL/vmmm3jpuoo8+NuXjQVZxmKuhDApK0/cKw==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-riscv64@0.18.20: resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} engines: {node: '>=12'} @@ -7082,6 +7380,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-s390x@0.16.17: + resolution: {integrity: sha512-gzy7nUTO4UA4oZ2wAMXPNBGTzZFP7mss3aKR2hH+/4UUkCOyqmjXiKpzGrY2TlEUhbbejzXVKKGazYcQTZWA/w==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-s390x@0.18.20: resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} engines: {node: '>=12'} @@ -7090,6 +7397,15 @@ packages: requiresBuild: true optional: true + /@esbuild/linux-x64@0.16.17: + resolution: {integrity: sha512-mdPjPxfnmoqhgpiEArqi4egmBAMYvaObgn4poorpUaqmvzzbvqbowRllQ+ZgzGVMGKaPkqUmPDOOFQRUFDmeUw==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@esbuild/linux-x64@0.18.20: resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} engines: {node: '>=12'} @@ -7098,6 +7414,15 @@ packages: requiresBuild: true optional: true + /@esbuild/netbsd-x64@0.16.17: + resolution: {integrity: sha512-/PzmzD/zyAeTUsduZa32bn0ORug+Jd1EGGAUJvqfeixoEISYpGnAezN6lnJoskauoai0Jrs+XSyvDhppCPoKOA==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: false + optional: true + /@esbuild/netbsd-x64@0.18.20: resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} engines: {node: '>=12'} @@ -7106,6 +7431,15 @@ packages: requiresBuild: true optional: true + /@esbuild/openbsd-x64@0.16.17: + resolution: {integrity: sha512-2yaWJhvxGEz2RiftSk0UObqJa/b+rIAjnODJgv2GbGGpRwAfpgzyrg1WLK8rqA24mfZa9GvpjLcBBg8JHkoodg==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: false + optional: true + /@esbuild/openbsd-x64@0.18.20: resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} engines: {node: '>=12'} @@ -7114,6 +7448,15 @@ packages: requiresBuild: true optional: true + /@esbuild/sunos-x64@0.16.17: + resolution: {integrity: sha512-xtVUiev38tN0R3g8VhRfN7Zl42YCJvyBhRKw1RJjwE1d2emWTVToPLNEQj/5Qxc6lVFATDiy6LjVHYhIPrLxzw==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: false + optional: true + /@esbuild/sunos-x64@0.18.20: resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} engines: {node: '>=12'} @@ -7122,6 +7465,15 @@ packages: requiresBuild: true optional: true + /@esbuild/win32-arm64@0.16.17: + resolution: {integrity: sha512-ga8+JqBDHY4b6fQAmOgtJJue36scANy4l/rL97W+0wYmijhxKetzZdKOJI7olaBaMhWt8Pac2McJdZLxXWUEQw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: false + optional: true + /@esbuild/win32-arm64@0.18.20: resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} engines: {node: '>=12'} @@ -7130,6 +7482,15 @@ packages: requiresBuild: true optional: true + /@esbuild/win32-ia32@0.16.17: + resolution: {integrity: sha512-WnsKaf46uSSF/sZhwnqE4L/F89AYNMiD4YtEcYekBt9Q7nj0DiId2XH2Ng2PHM54qi5oPrQ8luuzGszqi/veig==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: false + optional: true + /@esbuild/win32-ia32@0.18.20: resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} engines: {node: '>=12'} @@ -7138,6 +7499,15 @@ packages: requiresBuild: true optional: true + /@esbuild/win32-x64@0.16.17: + resolution: {integrity: sha512-y+EHuSchhL7FjHgvQL/0fnnFmO4T1bhvWANX6gcnqTjtnKWbTvUMCpGnv2+t+31d7RzyEAYAd4u2fnIhHL6N/Q==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + /@esbuild/win32-x64@0.18.20: resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} engines: {node: '>=12'} @@ -7164,7 +7534,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) espree: 9.6.1 globals: 13.24.0 ignore: 5.3.0 @@ -7179,55 +7549,395 @@ packages: resolution: {integrity: sha512-qQfo2mxH5yVom1kacMtZZJFVdW+E70mqHMJvVg6WTLo+VBuQJ4TojZlfWBjK0ve5BdEeNAVxOsl/nvNMpJOaJA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - /@expo/spawn-async@1.7.2: - resolution: {integrity: sha512-QdWi16+CHB9JYP7gma19OVVg0BFkvU8zNj9GjWorYI8Iv8FUxjOCcYRuAmX4s/h91e4e7BPsskc8cSrZYho9Ew==} - engines: {node: '>=12'} + /@eth-optimism/contracts@0.5.40(ethers@6.10.0): + resolution: {integrity: sha512-MrzV0nvsymfO/fursTB7m/KunkPsCndltVgfdHaT1Aj5Vi6R/doKIGGkOofHX+8B6VMZpuZosKCMQ5lQuqjt8w==} + peerDependencies: + ethers: ^5 dependencies: - cross-spawn: 7.0.3 + '@eth-optimism/core-utils': 0.12.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + ethers: 6.10.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate dev: false - /@floating-ui/core@1.5.3: - resolution: {integrity: sha512-O0WKDOo0yhJuugCx6trZQj5jVJ9yR0ystG2JaNAemYUWce+pmM6WUEFIibnWyEJKdrDxhm75NoSRME35FNaM/Q==} - dependencies: - '@floating-ui/utils': 0.2.1 + /@eth-optimism/core-utils@0.12.0: + resolution: {integrity: sha512-qW+7LZYCz7i8dRa7SRlUKIo1VBU8lvN0HeXCxJR+z+xtMzMQpPds20XJNCMclszxYQHkXY00fOT6GvFw9ZL6nw==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/providers': 5.7.2 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + bufio: 1.2.1 + chai: 4.4.1 + transitivePeerDependencies: + - bufferutil + - utf-8-validate dev: false - /@floating-ui/dom@1.5.4: - resolution: {integrity: sha512-jByEsHIY+eEdCjnTVu+E3ephzTOzkQ8hgUfGwos+bg7NlH33Zc5uO+QHz1mrQUOgIKKDD1RtS201P9NvAfq3XQ==} + /@ethereumjs/rlp@4.0.1: + resolution: {integrity: sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw==} + engines: {node: '>=14'} + hasBin: true + + /@ethereumjs/util@8.1.0: + resolution: {integrity: sha512-zQ0IqbdX8FZ9aw11vP+dZkKDkS+kgIvQPHnSAXzP9pLu+Rfu3D3XEeLbicvoXJTYnhZiPmsZUxgdzXwNKxRPbA==} + engines: {node: '>=14'} dependencies: - '@floating-ui/core': 1.5.3 - '@floating-ui/utils': 0.2.1 - dev: false + '@ethereumjs/rlp': 4.0.1 + ethereum-cryptography: 2.1.3 + micro-ftch: 0.3.1 - /@floating-ui/react-dom@2.0.4(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-CF8k2rgKeh/49UrnIBs4BdxPUV6vize/Db1d/YbCLyp9GiVZ0BEwf5AiDSxJRCr6yOkGqTFHtmrULxkEfYZ7dQ==} - peerDependencies: - react: '>=16.8.0' - react-dom: '>=16.8.0' + /@ethersproject/abi@5.7.0: + resolution: {integrity: sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==} dependencies: - '@floating-ui/dom': 1.5.4 - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - dev: false + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 - /@floating-ui/react@0.24.8(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-AuYeDoaR8jtUlUXtZ1IJ/6jtBkGnSpJXbGNzokBL87VDJ8opMq1Bgrc0szhK482ReQY6KZsMoZCVSb4xwalkBA==} - peerDependencies: - react: '>=16.8.0' - react-dom: '>=16.8.0' + /@ethersproject/abstract-provider@5.7.0: + resolution: {integrity: sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==} dependencies: - '@floating-ui/react-dom': 2.0.4(react-dom@18.2.0)(react@18.2.0) - aria-hidden: 1.2.3 - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - tabbable: 6.2.0 - dev: false + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 - /@floating-ui/react@0.25.4(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-lWRQ/UiTvSIBxohn0/2HFHEmnmOVRjl7j6XcRJuLH0ls6f/9AyHMWVzkAJFuwx0n9gaEeCmg9VccCSCJzbEJig==} - peerDependencies: - react: '>=16.8.0' - react-dom: '>=16.8.0' + /@ethersproject/abstract-signer@5.7.0: + resolution: {integrity: sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + + /@ethersproject/address@5.7.0: + resolution: {integrity: sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/rlp': 5.7.0 + + /@ethersproject/base64@5.7.0: + resolution: {integrity: sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==} + dependencies: + '@ethersproject/bytes': 5.7.0 + + /@ethersproject/basex@5.7.0: + resolution: {integrity: sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/properties': 5.7.0 + + /@ethersproject/bignumber@5.7.0: + resolution: {integrity: sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + bn.js: 5.2.1 + + /@ethersproject/bytes@5.7.0: + resolution: {integrity: sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==} + dependencies: + '@ethersproject/logger': 5.7.0 + + /@ethersproject/constants@5.7.0: + resolution: {integrity: sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + + /@ethersproject/contracts@5.7.0: + resolution: {integrity: sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/transactions': 5.7.0 + + /@ethersproject/hash@5.7.0: + resolution: {integrity: sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + + /@ethersproject/hdnode@5.7.0: + resolution: {integrity: sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/wordlists': 5.7.0 + + /@ethersproject/json-wallets@5.7.0: + resolution: {integrity: sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + aes-js: 3.0.0 + scrypt-js: 3.0.1 + + /@ethersproject/keccak256@5.7.0: + resolution: {integrity: sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==} + dependencies: + '@ethersproject/bytes': 5.7.0 + js-sha3: 0.8.0 + + /@ethersproject/logger@5.7.0: + resolution: {integrity: sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==} + + /@ethersproject/networks@5.7.1: + resolution: {integrity: sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==} + dependencies: + '@ethersproject/logger': 5.7.0 + + /@ethersproject/pbkdf2@5.7.0: + resolution: {integrity: sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/sha2': 5.7.0 + + /@ethersproject/properties@5.7.0: + resolution: {integrity: sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==} + dependencies: + '@ethersproject/logger': 5.7.0 + + /@ethersproject/providers@5.7.2: + resolution: {integrity: sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + bech32: 1.1.4 + ws: 7.4.6 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /@ethersproject/random@5.7.0: + resolution: {integrity: sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + + /@ethersproject/rlp@5.7.0: + resolution: {integrity: sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + + /@ethersproject/sha2@5.7.0: + resolution: {integrity: sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + hash.js: 1.1.7 + + /@ethersproject/signing-key@5.7.0: + resolution: {integrity: sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + bn.js: 5.2.1 + elliptic: 6.5.4 + hash.js: 1.1.7 + + /@ethersproject/solidity@5.7.0: + resolution: {integrity: sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + + /@ethersproject/strings@5.7.0: + resolution: {integrity: sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + + /@ethersproject/transactions@5.7.0: + resolution: {integrity: sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==} + dependencies: + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + + /@ethersproject/units@5.7.0: + resolution: {integrity: sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + + /@ethersproject/wallet@5.7.0: + resolution: {integrity: sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/json-wallets': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/wordlists': 5.7.0 + + /@ethersproject/web@5.7.1: + resolution: {integrity: sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==} + dependencies: + '@ethersproject/base64': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + + /@ethersproject/wordlists@5.7.0: + resolution: {integrity: sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + + /@expo/spawn-async@1.7.2: + resolution: {integrity: sha512-QdWi16+CHB9JYP7gma19OVVg0BFkvU8zNj9GjWorYI8Iv8FUxjOCcYRuAmX4s/h91e4e7BPsskc8cSrZYho9Ew==} + engines: {node: '>=12'} + dependencies: + cross-spawn: 7.0.3 + dev: false + + /@fastify/busboy@2.1.0: + resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==} + engines: {node: '>=14'} + + /@floating-ui/core@1.5.3: + resolution: {integrity: sha512-O0WKDOo0yhJuugCx6trZQj5jVJ9yR0ystG2JaNAemYUWce+pmM6WUEFIibnWyEJKdrDxhm75NoSRME35FNaM/Q==} + dependencies: + '@floating-ui/utils': 0.2.1 + dev: false + + /@floating-ui/dom@1.5.4: + resolution: {integrity: sha512-jByEsHIY+eEdCjnTVu+E3ephzTOzkQ8hgUfGwos+bg7NlH33Zc5uO+QHz1mrQUOgIKKDD1RtS201P9NvAfq3XQ==} + dependencies: + '@floating-ui/core': 1.5.3 + '@floating-ui/utils': 0.2.1 + dev: false + + /@floating-ui/react-dom@2.0.4(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-CF8k2rgKeh/49UrnIBs4BdxPUV6vize/Db1d/YbCLyp9GiVZ0BEwf5AiDSxJRCr6yOkGqTFHtmrULxkEfYZ7dQ==} + peerDependencies: + react: '>=16.8.0' + react-dom: '>=16.8.0' + dependencies: + '@floating-ui/dom': 1.5.4 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + + /@floating-ui/react@0.24.8(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-AuYeDoaR8jtUlUXtZ1IJ/6jtBkGnSpJXbGNzokBL87VDJ8opMq1Bgrc0szhK482ReQY6KZsMoZCVSb4xwalkBA==} + peerDependencies: + react: '>=16.8.0' + react-dom: '>=16.8.0' + dependencies: + '@floating-ui/react-dom': 2.0.4(react-dom@18.2.0)(react@18.2.0) + aria-hidden: 1.2.3 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + tabbable: 6.2.0 + dev: false + + /@floating-ui/react@0.25.4(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-lWRQ/UiTvSIBxohn0/2HFHEmnmOVRjl7j6XcRJuLH0ls6f/9AyHMWVzkAJFuwx0n9gaEeCmg9VccCSCJzbEJig==} + peerDependencies: + react: '>=16.8.0' + react-dom: '>=16.8.0' dependencies: '@floating-ui/react-dom': 2.0.4(react-dom@18.2.0)(react@18.2.0) '@floating-ui/utils': 0.1.6 @@ -7452,7 +8162,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 2.0.2 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -7600,7 +8310,7 @@ packages: resolution: {integrity: sha512-XdQLk242Cpcsc9a3Cz1ktOE5ysTo2TpxdeFQEPwMm8Z/+F/S6ZxBDdHYJL09srXWz3hkJr3oS2FPuMZNH1HIxw==} engines: {node: ^12.16.0 || >=13.7.0} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) picocolors: 1.0.0 transitivePeerDependencies: - supports-color @@ -7822,6 +8532,16 @@ packages: react: 18.2.0 dev: false + /@metamask/eth-sig-util@4.0.1: + resolution: {integrity: sha512-tghyZKLHZjcdlDqCA3gNZmLeR0XvOE9U1qoQO9ohyAZT6Pya+H9vkBPcsyXytmYLNgVoin7CKCmweo/R43V+tQ==} + engines: {node: '>=12.0.0'} + dependencies: + ethereumjs-abi: 0.6.8 + ethereumjs-util: 6.2.1 + ethjs-util: 0.1.6 + tweetnacl: 1.0.3 + tweetnacl-util: 0.15.1 + /@metamask/safe-event-emitter@2.0.0: resolution: {integrity: sha512-/kSXhY692qiV1MXu6EeOZvg5nECLclxNXcKCxJ3cXQgYuRymRHpdx/t7JXfsK+JLjwA1e1c1/SBrlQYpusC29Q==} dev: false @@ -7831,7 +8551,7 @@ packages: engines: {node: '>=14.0.0'} dependencies: '@types/debug': 4.1.12 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) semver: 7.5.4 superstruct: 1.0.3 transitivePeerDependencies: @@ -8202,23 +8922,25 @@ packages: resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} dependencies: '@noble/hashes': 1.3.2 - dev: false /@noble/curves@1.3.0: resolution: {integrity: sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA==} dependencies: '@noble/hashes': 1.3.3 - dev: false + + /@noble/hashes@1.2.0: + resolution: {integrity: sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==} /@noble/hashes@1.3.2: resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} engines: {node: '>= 16'} - dev: false /@noble/hashes@1.3.3: resolution: {integrity: sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==} engines: {node: '>= 16'} - dev: false + + /@noble/secp256k1@1.7.1: + resolution: {integrity: sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==} /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} @@ -8238,6 +8960,344 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.16.0 + /@nomicfoundation/ethereumjs-block@5.0.2: + resolution: {integrity: sha512-hSe6CuHI4SsSiWWjHDIzWhSiAVpzMUcDRpWYzN0T9l8/Rz7xNn3elwVOJ/tAyS0LqL6vitUD78Uk7lQDXZun7Q==} + engines: {node: '>=14'} + dependencies: + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + ethereum-cryptography: 0.1.3 + ethers: 5.7.2 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /@nomicfoundation/ethereumjs-blockchain@7.0.2: + resolution: {integrity: sha512-8UUsSXJs+MFfIIAKdh3cG16iNmWzWC/91P40sazNvrqhhdR/RtGDlFk2iFTGbBAZPs2+klZVzhRX8m2wvuvz3w==} + engines: {node: '>=14'} + dependencies: + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-ethash': 3.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + abstract-level: 1.0.4 + debug: 4.3.4(supports-color@8.1.1) + ethereum-cryptography: 0.1.3 + level: 8.0.0 + lru-cache: 5.1.1 + memory-level: 1.0.0 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + /@nomicfoundation/ethereumjs-common@4.0.2: + resolution: {integrity: sha512-I2WGP3HMGsOoycSdOTSqIaES0ughQTueOsddJ36aYVpI3SN8YSusgRFLwzDJwRFVIYDKx/iJz0sQ5kBHVgdDwg==} + dependencies: + '@nomicfoundation/ethereumjs-util': 9.0.2 + crc-32: 1.2.2 + + /@nomicfoundation/ethereumjs-ethash@3.0.2: + resolution: {integrity: sha512-8PfoOQCcIcO9Pylq0Buijuq/O73tmMVURK0OqdjhwqcGHYC2PwhbajDh7GZ55ekB0Px197ajK3PQhpKoiI/UPg==} + engines: {node: '>=14'} + dependencies: + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + abstract-level: 1.0.4 + bigint-crypto-utils: 3.3.0 + ethereum-cryptography: 0.1.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /@nomicfoundation/ethereumjs-evm@2.0.2: + resolution: {integrity: sha512-rBLcUaUfANJxyOx9HIdMX6uXGin6lANCulIm/pjMgRqfiCRMZie3WKYxTSd8ZE/d+qT+zTedBF4+VHTdTSePmQ==} + engines: {node: '>=14'} + dependencies: + '@ethersproject/providers': 5.7.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + debug: 4.3.4(supports-color@8.1.1) + ethereum-cryptography: 0.1.3 + mcl-wasm: 0.7.9 + rustbn.js: 0.2.0 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + /@nomicfoundation/ethereumjs-rlp@5.0.2: + resolution: {integrity: sha512-QwmemBc+MMsHJ1P1QvPl8R8p2aPvvVcKBbvHnQOKBpBztEo0omN0eaob6FeZS/e3y9NSe+mfu3nNFBHszqkjTA==} + engines: {node: '>=14'} + hasBin: true + + /@nomicfoundation/ethereumjs-statemanager@2.0.2: + resolution: {integrity: sha512-dlKy5dIXLuDubx8Z74sipciZnJTRSV/uHG48RSijhgm1V7eXYFC567xgKtsKiVZB1ViTP9iFL4B6Je0xD6X2OA==} + dependencies: + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + debug: 4.3.4(supports-color@8.1.1) + ethereum-cryptography: 0.1.3 + ethers: 5.7.2 + js-sdsl: 4.4.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + /@nomicfoundation/ethereumjs-trie@6.0.2: + resolution: {integrity: sha512-yw8vg9hBeLYk4YNg5MrSJ5H55TLOv2FSWUTROtDtTMMmDGROsAu+0tBjiNGTnKRi400M6cEzoFfa89Fc5k8NTQ==} + engines: {node: '>=14'} + dependencies: + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + '@types/readable-stream': 2.3.15 + ethereum-cryptography: 0.1.3 + readable-stream: 3.6.2 + + /@nomicfoundation/ethereumjs-tx@5.0.2: + resolution: {integrity: sha512-T+l4/MmTp7VhJeNloMkM+lPU3YMUaXdcXgTGCf8+ZFvV9NYZTRLFekRwlG6/JMmVfIfbrW+dRRJ9A6H5Q/Z64g==} + engines: {node: '>=14'} + dependencies: + '@chainsafe/ssz': 0.9.4 + '@ethersproject/providers': 5.7.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + ethereum-cryptography: 0.1.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /@nomicfoundation/ethereumjs-util@9.0.2: + resolution: {integrity: sha512-4Wu9D3LykbSBWZo8nJCnzVIYGvGCuyiYLIJa9XXNVt1q1jUzHdB+sJvx95VGCpPkCT+IbLecW6yfzy3E1bQrwQ==} + engines: {node: '>=14'} + dependencies: + '@chainsafe/ssz': 0.10.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + ethereum-cryptography: 0.1.3 + + /@nomicfoundation/ethereumjs-vm@7.0.2: + resolution: {integrity: sha512-Bj3KZT64j54Tcwr7Qm/0jkeZXJMfdcAtRBedou+Hx0dPOSIgqaIr0vvLwP65TpHbak2DmAq+KJbW2KNtIoFwvA==} + engines: {node: '>=14'} + dependencies: + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-blockchain': 7.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-evm': 2.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-statemanager': 2.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + debug: 4.3.4(supports-color@8.1.1) + ethereum-cryptography: 0.1.3 + mcl-wasm: 0.7.9 + rustbn.js: 0.2.0 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + /@nomicfoundation/hardhat-chai-matchers@2.0.3(@nomicfoundation/hardhat-ethers@3.0.5)(chai@4.4.1)(ethers@6.10.0)(hardhat@2.19.4): + resolution: {integrity: sha512-A40s7EAK4Acr8UP1Yudgi9GGD9Cca/K3LHt3DzmRIje14lBfHtg9atGQ7qK56vdPcTwKmeaGn30FzxMUfPGEMw==} + peerDependencies: + '@nomicfoundation/hardhat-ethers': ^3.0.0 + chai: ^4.2.0 + ethers: ^6.1.0 + hardhat: ^2.9.4 + dependencies: + '@nomicfoundation/hardhat-ethers': 3.0.5(ethers@6.10.0)(hardhat@2.19.4) + '@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.10.0 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + ordinal: 1.0.3 + + /@nomicfoundation/hardhat-ethers@3.0.5(ethers@6.10.0)(hardhat@2.19.4): + 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.10.0 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + lodash.isequal: 4.5.0 + transitivePeerDependencies: + - supports-color + + /@nomicfoundation/hardhat-network-helpers@1.0.10(hardhat@2.19.4): + resolution: {integrity: sha512-R35/BMBlx7tWN5V6d/8/19QCwEmIdbnA4ZrsuXgvs8i2qFx5i7h6mH5pBS4Pwi4WigLH+upl6faYusrNPuzMrQ==} + peerDependencies: + hardhat: ^2.9.5 + dependencies: + ethereumjs-util: 7.1.5 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + + /@nomicfoundation/hardhat-toolbox@3.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.3)(@nomicfoundation/hardhat-ethers@3.0.5)(@nomicfoundation/hardhat-network-helpers@1.0.10)(@nomicfoundation/hardhat-verify@1.1.1)(@typechain/ethers-v6@0.4.3)(@typechain/hardhat@8.0.3)(@types/chai@4.3.11)(@types/mocha@10.0.6)(@types/node@20.10.6)(chai@4.4.1)(ethers@6.10.0)(hardhat-gas-reporter@1.0.9)(hardhat@2.19.4)(solidity-coverage@0.8.5)(ts-node@10.9.2)(typechain@8.3.2)(typescript@5.3.3): + resolution: {integrity: sha512-MsteDXd0UagMksqm9KvcFG6gNKYNa3GGNCy73iQ6bEasEgg2v8Qjl6XA5hjs8o5UD5A3153B6W2BIVJ8SxYUtA==} + peerDependencies: + '@nomicfoundation/hardhat-chai-matchers': ^2.0.0 + '@nomicfoundation/hardhat-ethers': ^3.0.0 + '@nomicfoundation/hardhat-network-helpers': ^1.0.0 + '@nomicfoundation/hardhat-verify': ^1.0.0 + '@typechain/ethers-v6': ^0.4.0 + '@typechain/hardhat': ^8.0.0 + '@types/chai': ^4.2.0 + '@types/mocha': '>=9.1.0' + '@types/node': '>=12.0.0' + chai: ^4.2.0 + ethers: ^6.4.0 + hardhat: ^2.11.0 + hardhat-gas-reporter: ^1.0.8 + solidity-coverage: ^0.8.1 + ts-node: '>=8.0.0' + typechain: ^8.2.0 + typescript: '>=4.5.0' + dependencies: + '@nomicfoundation/hardhat-chai-matchers': 2.0.3(@nomicfoundation/hardhat-ethers@3.0.5)(chai@4.4.1)(ethers@6.10.0)(hardhat@2.19.4) + '@nomicfoundation/hardhat-ethers': 3.0.5(ethers@6.10.0)(hardhat@2.19.4) + '@nomicfoundation/hardhat-network-helpers': 1.0.10(hardhat@2.19.4) + '@nomicfoundation/hardhat-verify': 1.1.1(hardhat@2.19.4) + '@typechain/ethers-v6': 0.4.3(ethers@6.10.0)(typechain@8.3.2)(typescript@5.3.3) + '@typechain/hardhat': 8.0.3(@typechain/ethers-v6@0.4.3)(ethers@6.10.0)(hardhat@2.19.4)(typechain@8.3.2) + '@types/chai': 4.3.11 + '@types/mocha': 10.0.6 + '@types/node': 20.10.6 + chai: 4.4.1 + ethers: 6.10.0 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + hardhat-gas-reporter: 1.0.9(hardhat@2.19.4) + solidity-coverage: 0.8.5(hardhat@2.19.4) + ts-node: 10.9.2(@types/node@20.10.6)(typescript@5.3.3) + typechain: 8.3.2(typescript@5.3.3) + typescript: 5.3.3 + dev: false + + /@nomicfoundation/hardhat-verify@1.1.1(hardhat@2.19.4): + resolution: {integrity: sha512-9QsTYD7pcZaQFEA3tBb/D/oCStYDiEVDN7Dxeo/4SCyHRSm86APypxxdOMEPlGmXsAvd+p1j/dTODcpxb8aztA==} + peerDependencies: + hardhat: ^2.0.4 + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/address': 5.7.0 + cbor: 8.1.0 + chalk: 2.4.2 + debug: 4.3.4(supports-color@8.1.1) + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + lodash.clonedeep: 4.5.0 + semver: 6.3.1 + table: 6.8.1 + undici: 5.28.2 + transitivePeerDependencies: + - supports-color + + /@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1: + resolution: {integrity: sha512-KcTodaQw8ivDZyF+D76FokN/HdpgGpfjc/gFCImdLUyqB6eSWVaZPazMbeAjmfhx3R0zm/NYVzxwAokFKgrc0w==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-darwin-x64@0.1.1: + resolution: {integrity: sha512-XhQG4BaJE6cIbjAVtzGOGbK3sn1BO9W29uhk9J8y8fZF1DYz0Doj8QDMfpMu+A6TjPDs61lbsmeYodIDnfveSA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-freebsd-x64@0.1.1: + resolution: {integrity: sha512-GHF1VKRdHW3G8CndkwdaeLkVBi5A9u2jwtlS7SLhBc8b5U/GcoL39Q+1CSO3hYqePNP+eV5YI7Zgm0ea6kMHoA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-linux-arm64-gnu@0.1.1: + resolution: {integrity: sha512-g4Cv2fO37ZsUENQ2vwPnZc2zRenHyAxHcyBjKcjaSmmkKrFr64yvzeNO8S3GBFCo90rfochLs99wFVGT/0owpg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-linux-arm64-musl@0.1.1: + resolution: {integrity: sha512-WJ3CE5Oek25OGE3WwzK7oaopY8xMw9Lhb0mlYuJl/maZVo+WtP36XoQTb7bW/i8aAdHW5Z+BqrHMux23pvxG3w==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-linux-x64-gnu@0.1.1: + resolution: {integrity: sha512-5WN7leSr5fkUBBjE4f3wKENUy9HQStu7HmWqbtknfXkkil+eNWiBV275IOlpXku7v3uLsXTOKpnnGHJYI2qsdA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-linux-x64-musl@0.1.1: + resolution: {integrity: sha512-KdYMkJOq0SYPQMmErv/63CwGwMm5XHenEna9X9aB8mQmhDBrYrlAOSsIPgFCUSL0hjxE3xHP65/EPXR/InD2+w==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-win32-arm64-msvc@0.1.1: + resolution: {integrity: sha512-VFZASBfl4qiBYwW5xeY20exWhmv6ww9sWu/krWSesv3q5hA0o1JuzmPHR4LPN6SUZj5vcqci0O6JOL8BPw+APg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-win32-ia32-msvc@0.1.1: + resolution: {integrity: sha512-JnFkYuyCSA70j6Si6cS1A9Gh1aHTEb8kOTBApp/c7NRTFGNMH8eaInKlyuuiIbvYFhlXW4LicqyYuWNNq9hkpQ==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer-win32-x64-msvc@0.1.1: + resolution: {integrity: sha512-HrVJr6+WjIXGnw3Q9u6KQcbZCtk0caVWhCdFADySvRyUxJ8PnzlaP+MhwNE8oyT8OZ6ejHBRrrgjSqDCFXGirw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + requiresBuild: true + optional: true + + /@nomicfoundation/solidity-analyzer@0.1.1: + resolution: {integrity: sha512-1LMtXj1puAxyFusBgUIy5pZk3073cNXYnXUpuNKFghHbIit/xZgbk0AokpUADbNm3gyD6bFWl3LRFh3dhVdREg==} + engines: {node: '>= 12'} + optionalDependencies: + '@nomicfoundation/solidity-analyzer-darwin-arm64': 0.1.1 + '@nomicfoundation/solidity-analyzer-darwin-x64': 0.1.1 + '@nomicfoundation/solidity-analyzer-freebsd-x64': 0.1.1 + '@nomicfoundation/solidity-analyzer-linux-arm64-gnu': 0.1.1 + '@nomicfoundation/solidity-analyzer-linux-arm64-musl': 0.1.1 + '@nomicfoundation/solidity-analyzer-linux-x64-gnu': 0.1.1 + '@nomicfoundation/solidity-analyzer-linux-x64-musl': 0.1.1 + '@nomicfoundation/solidity-analyzer-win32-arm64-msvc': 0.1.1 + '@nomicfoundation/solidity-analyzer-win32-ia32-msvc': 0.1.1 + '@nomicfoundation/solidity-analyzer-win32-x64-msvc': 0.1.1 + /@octokit/app@14.0.2: resolution: {integrity: sha512-NCSCktSx+XmjuSUVn2dLfqQ9WIYePGP95SDJs4I9cn/0ZkeXcPkaoCLl64Us3dRKL2ozC7hArwze5Eu+/qt1tg==} engines: {node: '>= 18'} @@ -8497,6 +9557,56 @@ packages: aggregate-error: 3.1.0 dev: false + /@opencensus/core@0.0.8: + resolution: {integrity: sha512-yUFT59SFhGMYQgX0PhoTR0LBff2BEhPrD9io1jWfF/VDbakRfs6Pq60rjv0Z7iaTav5gQlttJCX2+VPxFWCuoQ==} + engines: {node: '>=6.0'} + dependencies: + continuation-local-storage: 3.2.1 + log-driver: 1.2.7 + semver: 5.7.2 + shimmer: 1.2.1 + uuid: 3.4.0 + dev: true + + /@opencensus/core@0.0.9: + resolution: {integrity: sha512-31Q4VWtbzXpVUd2m9JS6HEaPjlKvNMOiF7lWKNmXF84yUcgfAFL5re7/hjDmdyQbOp32oGc+RFV78jXIldVz6Q==} + engines: {node: '>=6.0'} + dependencies: + continuation-local-storage: 3.2.1 + log-driver: 1.2.7 + semver: 5.7.2 + shimmer: 1.2.1 + uuid: 3.4.0 + dev: true + + /@opencensus/propagation-b3@0.0.8: + resolution: {integrity: sha512-PffXX2AL8Sh0VHQ52jJC4u3T0H6wDK6N/4bg7xh4ngMYOIi13aR1kzVvX1sVDBgfGwDOkMbl4c54Xm3tlPx/+A==} + engines: {node: '>=6.0'} + dependencies: + '@opencensus/core': 0.0.8 + uuid: 3.4.0 + dev: true + + /@openzeppelin/contracts-upgradeable@4.9.5: + resolution: {integrity: sha512-f7L1//4sLlflAN7fVzJLoRedrf5Na3Oal5PZfIq55NFcVZ90EpV1q5xOvL4lFvg3MNICSDr2hH0JUBxwlxcoPg==} + dev: false + + /@openzeppelin/contracts@3.4.2: + resolution: {integrity: sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA==} + dev: false + + /@openzeppelin/contracts@3.4.2-solc-0.7: + resolution: {integrity: sha512-W6QmqgkADuFcTLzHL8vVoNBtkwjvQRpYIAom7KiUNoLKghyx3FgH0GBjt8NRvigV1ZmMOBllvE1By1C+bi8WpA==} + dev: false + + /@openzeppelin/contracts@4.3.3: + resolution: {integrity: sha512-tDBopO1c98Yk7Cv/PZlHqrvtVjlgK5R4J6jxLwoO7qxK4xqOiZG+zSkIvGFpPZ0ikc3QOED3plgdqjgNTnBc7g==} + dev: false + + /@openzeppelin/contracts@4.9.5: + resolution: {integrity: sha512-ZK+W5mVhRppff9BE6YdR8CC52C8zAvsVAiWhEtQ5+oNxFE6h1WdeWo+FJSF8KKvtxxVYZ7MTP/5KoVpAU3aSWg==} + dev: false + /@panva/hkdf@1.1.1: resolution: {integrity: sha512-dhPeilub1NuIG0X5Kvhh9lH4iW3ZsHlnzwgwbOlgwQ2wG1IqFzsgHqmKPk3WzsdWAeaxKJxgM0+W433RmN45GA==} dev: false @@ -10172,9 +11282,72 @@ packages: react: 18.2.0 dev: false - /@pnpm/config.env-replace@1.1.0: - resolution: {integrity: sha512-htyl8TWnKL7K/ESFa1oW2UB5lVDxuF5DpM7tBi6Hu2LNL3mWkIzNLG6N4zoCUP1lCKNxWy/3iu8mS8MvToGd6w==} - engines: {node: '>=12.22.0'} + /@pm2/agent@2.0.3: + resolution: {integrity: sha512-xkqqCoTf5VsciMqN0vb9jthW7olVAi4KRFNddCc7ZkeJZ3i8QwZANr4NSH2H5DvseRFHq7MiPspRY/EWAFWWTg==} + dependencies: + async: 3.2.5 + chalk: 3.0.0 + dayjs: 1.8.36 + debug: 4.3.4(supports-color@8.1.1) + eventemitter2: 5.0.1 + fast-json-patch: 3.1.1 + fclone: 1.0.11 + nssocket: 0.6.0 + pm2-axon: 4.0.1 + pm2-axon-rpc: 0.7.1 + proxy-agent: 6.3.1 + semver: 7.5.4 + ws: 7.4.6 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: true + + /@pm2/io@5.0.2: + resolution: {integrity: sha512-XAvrNoQPKOyO/jJyCu8jPhLzlyp35MEf7w/carHXmWKddPzeNOFSEpSEqMzPDawsvpxbE+i918cNN+MwgVsStA==} + engines: {node: '>=6.0'} + dependencies: + '@opencensus/core': 0.0.9 + '@opencensus/propagation-b3': 0.0.8 + async: 2.6.4 + debug: 4.3.4(supports-color@8.1.1) + eventemitter2: 6.4.9 + require-in-the-middle: 5.2.0 + semver: 7.5.4 + shimmer: 1.2.1 + signal-exit: 3.0.7 + tslib: 1.9.3 + transitivePeerDependencies: + - supports-color + dev: true + + /@pm2/js-api@0.8.0: + resolution: {integrity: sha512-nmWzrA/BQZik3VBz+npRcNIu01kdBhWL0mxKmP1ciF/gTcujPTQqt027N9fc1pK9ERM8RipFhymw7RcmCyOEYA==} + engines: {node: '>=4.0'} + dependencies: + async: 2.6.4 + debug: 4.3.4(supports-color@8.1.1) + eventemitter2: 6.4.9 + extrareqp2: 1.0.0(debug@4.3.4) + ws: 7.5.9 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: true + + /@pm2/pm2-version-check@1.0.4: + resolution: {integrity: sha512-SXsM27SGH3yTWKc2fKR4SYNxsmnvuBQ9dd6QHtEWmiZ/VqaOYPAIlS8+vMcn27YLtAEBGvNRSh3TPNvtjZgfqA==} + dependencies: + debug: 4.3.4(supports-color@8.1.1) + transitivePeerDependencies: + - supports-color + dev: true + + /@pnpm/config.env-replace@1.1.0: + resolution: {integrity: sha512-htyl8TWnKL7K/ESFa1oW2UB5lVDxuF5DpM7tBi6Hu2LNL3mWkIzNLG6N4zoCUP1lCKNxWy/3iu8mS8MvToGd6w==} + engines: {node: '>=12.22.0'} dev: false /@pnpm/network.ca-file@1.0.2: @@ -10227,7 +11400,7 @@ packages: engines: {node: '>=16.3.0'} hasBin: true dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) extract-zip: 2.0.1 progress: 2.0.3 proxy-agent: 6.3.1 @@ -11180,7 +12353,13 @@ packages: /@scure/base@1.1.5: resolution: {integrity: sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==} - dev: false + + /@scure/bip32@1.1.5: + resolution: {integrity: sha512-XyNh1rB0SkEqd3tXcXMi+Xe1fvg+kUIcoRIEujP1Jgv7DqW2r9lg3Ah0NkFaCs9sTkQAQA8kw7xiRXzENi9Rtw==} + dependencies: + '@noble/hashes': 1.2.0 + '@noble/secp256k1': 1.7.1 + '@scure/base': 1.1.5 /@scure/bip32@1.3.2: resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} @@ -11188,14 +12367,94 @@ packages: '@noble/curves': 1.2.0 '@noble/hashes': 1.3.2 '@scure/base': 1.1.5 - dev: false + + /@scure/bip32@1.3.3: + resolution: {integrity: sha512-LJaN3HwRbfQK0X1xFSi0Q9amqOgzQnnDngIt+ZlsBC3Bm7/nE7K0kwshZHyaru79yIVRv/e1mQAjZyuZG6jOFQ==} + dependencies: + '@noble/curves': 1.3.0 + '@noble/hashes': 1.3.3 + '@scure/base': 1.1.5 + + /@scure/bip39@1.1.1: + resolution: {integrity: sha512-t+wDck2rVkh65Hmv280fYdVdY25J9YeEUIgn2LG1WM6gxFkGzcksoDiUkWVpVp3Oex9xGC68JU2dSbUfwZ2jPg==} + dependencies: + '@noble/hashes': 1.2.0 + '@scure/base': 1.1.5 /@scure/bip39@1.2.1: resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} dependencies: '@noble/hashes': 1.3.2 '@scure/base': 1.1.5 - dev: false + + /@scure/bip39@1.2.2: + resolution: {integrity: sha512-HYf9TUXG80beW+hGAt3TRM8wU6pQoYur9iNypTROm42dorCGmLnFe3eWjz3gOq6G62H2WRh0FCzAR1PI+29zIA==} + dependencies: + '@noble/hashes': 1.3.3 + '@scure/base': 1.1.5 + + /@sentry/core@5.30.0: + resolution: {integrity: sha512-TmfrII8w1PQZSZgPpUESqjB+jC6MvZJZdLtE/0hZ+SrnKhW3x5WlYLvTXZpcWePYBku7rl2wn1RZu6uT0qCTeg==} + engines: {node: '>=6'} + dependencies: + '@sentry/hub': 5.30.0 + '@sentry/minimal': 5.30.0 + '@sentry/types': 5.30.0 + '@sentry/utils': 5.30.0 + tslib: 1.14.1 + + /@sentry/hub@5.30.0: + resolution: {integrity: sha512-2tYrGnzb1gKz2EkMDQcfLrDTvmGcQPuWxLnJKXJvYTQDGLlEvi2tWz1VIHjunmOvJrB5aIQLhm+dcMRwFZDCqQ==} + engines: {node: '>=6'} + dependencies: + '@sentry/types': 5.30.0 + '@sentry/utils': 5.30.0 + tslib: 1.14.1 + + /@sentry/minimal@5.30.0: + resolution: {integrity: sha512-BwWb/owZKtkDX+Sc4zCSTNcvZUq7YcH3uAVlmh/gtR9rmUvbzAA3ewLuB3myi4wWRAMEtny6+J/FN/x+2wn9Xw==} + engines: {node: '>=6'} + dependencies: + '@sentry/hub': 5.30.0 + '@sentry/types': 5.30.0 + tslib: 1.14.1 + + /@sentry/node@5.30.0: + resolution: {integrity: sha512-Br5oyVBF0fZo6ZS9bxbJZG4ApAjRqAnqFFurMVJJdunNb80brh7a5Qva2kjhm+U6r9NJAB5OmDyPkA1Qnt+QVg==} + engines: {node: '>=6'} + dependencies: + '@sentry/core': 5.30.0 + '@sentry/hub': 5.30.0 + '@sentry/tracing': 5.30.0 + '@sentry/types': 5.30.0 + '@sentry/utils': 5.30.0 + cookie: 0.4.2 + https-proxy-agent: 5.0.1 + lru_map: 0.3.3 + tslib: 1.14.1 + transitivePeerDependencies: + - supports-color + + /@sentry/tracing@5.30.0: + resolution: {integrity: sha512-dUFowCr0AIMwiLD7Fs314Mdzcug+gBVo/+NCMyDw8tFxJkwWAKl7Qa2OZxLQ0ZHjakcj1hNKfCQJ9rhyfOl4Aw==} + engines: {node: '>=6'} + dependencies: + '@sentry/hub': 5.30.0 + '@sentry/minimal': 5.30.0 + '@sentry/types': 5.30.0 + '@sentry/utils': 5.30.0 + tslib: 1.14.1 + + /@sentry/types@5.30.0: + resolution: {integrity: sha512-R8xOqlSTZ+htqrfteCWU5Nk0CDN5ApUTvrlvBuiH1DyP6czDZ4ktbZB0hAgBlVcK0U+qpD3ag3Tqqpa5Q67rPw==} + engines: {node: '>=6'} + + /@sentry/utils@5.30.0: + resolution: {integrity: sha512-zaYmoH0NWWtvnJjC9/CBseXMtKHm/tm40sz3YfJRxeQjyzRqNQPgivpd9R/oDJCYj999mzdW382p/qi2ypjLww==} + engines: {node: '>=6'} + dependencies: + '@sentry/types': 5.30.0 + tslib: 1.14.1 /@sideway/address@4.1.4: resolution: {integrity: sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw==} @@ -11252,6 +12511,20 @@ packages: - utf-8-validate dev: false + /@solidity-parser/parser@0.14.5: + resolution: {integrity: sha512-6dKnHZn7fg/iQATVEzqyUOyEidbn05q7YA2mQ9hC0MMXhhV3/JrsxmFSYZAcr7j1yUP700LLhTruvJ3MiQmjJg==} + dependencies: + antlr4ts: 0.5.0-alpha.4 + + /@solidity-parser/parser@0.16.2: + resolution: {integrity: sha512-PI9NfoA3P8XK2VBkK5oIfRgKDsicwDZfkVq9ZTBCQYGOP1N2owgY2dyLGyU5/J/hQs8KRk55kdmvTLjy3Mu3vg==} + dependencies: + antlr4ts: 0.5.0-alpha.4 + + /@solidity-parser/parser@0.17.0: + resolution: {integrity: sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==} + dev: true + /@stablelib/aead@1.0.1: resolution: {integrity: sha512-q39ik6sxGHewqtO0nP4BuSe3db5G1fEJE8ukvngS2gLkBXyy6E7pLubhbYgnkDFv6V8cWaxcE4Xn0t6LWcJkyg==} dev: false @@ -12318,6 +13591,33 @@ packages: update-check: 1.5.4 dev: true + /@typechain/ethers-v6@0.4.3(ethers@6.10.0)(typechain@8.3.2)(typescript@5.3.3): + resolution: {integrity: sha512-TrxBsyb4ryhaY9keP6RzhFCviWYApcLCIRMPyWaKp2cZZrfaM3QBoxXTnw/eO4+DAY3l+8O0brNW0WgeQeOiDA==} + peerDependencies: + ethers: 6.x + typechain: ^8.3.1 + typescript: '>=4.7.0' + dependencies: + ethers: 6.10.0 + lodash: 4.17.21 + ts-essentials: 7.0.3(typescript@5.3.3) + typechain: 8.3.2(typescript@5.3.3) + typescript: 5.3.3 + + /@typechain/hardhat@8.0.3(@typechain/ethers-v6@0.4.3)(ethers@6.10.0)(hardhat@2.19.4)(typechain@8.3.2): + resolution: {integrity: sha512-MytSmJJn+gs7Mqrpt/gWkTCOpOQ6ZDfRrRT2gtZL0rfGe4QrU4x9ZdW15fFbVM/XTa+5EsKiOMYXhRABibNeng==} + peerDependencies: + '@typechain/ethers-v6': ^0.4.3 + ethers: ^6.1.0 + hardhat: ^2.9.9 + typechain: ^8.3.1 + dependencies: + '@typechain/ethers-v6': 0.4.3(ethers@6.10.0)(typechain@8.3.2)(typescript@5.3.3) + ethers: 6.10.0 + fs-extra: 9.1.0 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + typechain: 8.3.2(typescript@5.3.3) + /@types/acorn@4.0.6: resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==} dependencies: @@ -12328,6 +13628,16 @@ packages: resolution: {integrity: sha512-IWmFpqnVDvskYWnNSiu/qlRn80XlIOU0Gy5rKCl/NjhnI95pV8qIHs6L5b+bpHhyzuOSzjLgBcwgFSXrC1nZWA==} dev: false + /@types/bn.js@4.11.6: + resolution: {integrity: sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==} + dependencies: + '@types/node': 20.10.6 + + /@types/bn.js@5.1.5: + resolution: {integrity: sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==} + dependencies: + '@types/node': 20.10.6 + /@types/body-parser@1.19.5: resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} dependencies: @@ -12339,6 +13649,14 @@ packages: resolution: {integrity: sha512-ZYbcE2x7yrvNFJiU7xJGrpF/ihpkM7zKgw8bha3LNJSesvTtUNxbpzaT7WXBIryf6jovisrxTBvymxMeLLj1Mg==} dev: false + /@types/chai-as-promised@7.1.8: + resolution: {integrity: sha512-ThlRVIJhr69FLlh6IctTXFkmhtP3NpMZ2QGq69StYLyKZFp/HOp1VdKZj7RvfNWYYcJ1xlbLGLLWj1UvP5u/Gw==} + dependencies: + '@types/chai': 4.3.11 + + /@types/chai@4.3.11: + resolution: {integrity: sha512-qQR1dr2rGIHYlJulmr8Ioq3De0Le9E4MJ5AiaeAETJJpndT1uUNHsGFK3L/UIu+rbkQSdj8J/w2bCsBZc/Y5fQ==} + /@types/chrome@0.0.245: resolution: {integrity: sha512-bBdONkLO8wMbJK6iG0Q8ShFuh67Grnod+5OpClJaa8MuKJXP/Kjl3f8wRYeMOnQ0Q8HDgpUlopu8bvl9siR8/A==} dependencies: @@ -12346,6 +13664,11 @@ packages: '@types/har-format': 1.2.15 dev: true + /@types/concat-stream@1.6.1: + resolution: {integrity: sha512-eHE4cQPoj6ngxBZMvVf6Hw7Mh4jMW4U9lpGmS5GBPB9RYxlFg+CHaVN7ErNY4W9XfLIEn20b4VDYaIrbq0q4uA==} + dependencies: + '@types/node': 20.10.6 + /@types/connect@3.4.38: resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} dependencies: @@ -12421,6 +13744,12 @@ packages: resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} dev: false + /@types/ethereumjs-abi@0.6.5: + resolution: {integrity: sha512-2XOUOXXqYkWtZ5550hM0vdjwH3ccm1Q/4bowJWuXYmx2KpDTN7BrgADC563IYJdnltYnPrZhaHJxbuagjtNuAg==} + dependencies: + '@types/node': 20.10.6 + dev: false + /@types/express-serve-static-core@4.17.41: resolution: {integrity: sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==} dependencies: @@ -12449,6 +13778,11 @@ packages: resolution: {integrity: sha512-Kpi2GXQyYJdjL8mFclL1eDgihn1SIzorMZjD94kdPZh9E4VxGOeyjPxi5LpsM4Zku7P0reqegZTt2GxhmA9VBg==} dev: true + /@types/form-data@0.0.33: + resolution: {integrity: sha512-8BSvG1kGm83cyJITQMZSulnl6QV8jqAGreJsc5tPu1Jq0vTSOiY/k24Wx82JRpWwZSqrala6sd5rWi6aNXvqcw==} + dependencies: + '@types/node': 20.10.6 + /@types/glob@7.2.0: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: @@ -12535,6 +13869,9 @@ packages: /@types/lodash@4.14.202: resolution: {integrity: sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==} + /@types/lru-cache@5.1.1: + resolution: {integrity: sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==} + /@types/markdown-it@13.0.7: resolution: {integrity: sha512-U/CBi2YUUcTHBt5tjO2r5QV/x0Po6nsYwQU4Y04fBS6vfoImaiZ6f8bi3CjTCxBPQSO1LMyUqkByzi8AidyxfA==} dependencies: @@ -12580,6 +13917,9 @@ packages: resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} dev: true + /@types/mocha@10.0.6: + resolution: {integrity: sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==} + /@types/ms@0.7.34: resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==} dev: false @@ -12591,6 +13931,9 @@ packages: form-data: 4.0.0 dev: true + /@types/node@10.17.60: + resolution: {integrity: sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==} + /@types/node@12.20.55: resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} @@ -12598,6 +13941,9 @@ packages: resolution: {integrity: sha512-eEn8RkzZFcT0gb8qyi0CcfSOQnLE+NbGLIIaxGGmjn/N35v/C3M8ohxcpSlNlCv+H8vPpMGmrGDdCkzr8xu2tQ==} dev: false + /@types/node@18.15.13: + resolution: {integrity: sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==} + /@types/node@18.19.8: resolution: {integrity: sha512-g1pZtPhsvGVTwmeVoexWZLTQaOvXwoSq//pTL0DHeNzUDrFnir4fgETdhjhIxjVnN+hKOuh98+E1eMLnUXstFg==} dependencies: @@ -12613,6 +13959,9 @@ packages: resolution: {integrity: sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==} dev: true + /@types/node@8.10.66: + resolution: {integrity: sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw==} + /@types/normalize-package-data@2.4.4: resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} dev: true @@ -12620,10 +13969,18 @@ packages: /@types/parse-json@4.0.2: resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} + /@types/pbkdf2@3.1.2: + resolution: {integrity: sha512-uRwJqmiXmh9++aSu1VNEn3iIxWOhd8AHXNSdlaLfdAAdSTY9jYVeGWnzejM3dvrkbqE3/hyQkQQ29IFATEGlew==} + dependencies: + '@types/node': 20.10.6 + /@types/phoenix@1.6.4: resolution: {integrity: sha512-B34A7uot1Cv0XtaHRYDATltAdKx0BvVKNgYNqE4WjtPUa4VQJM7kxeXcVKaH+KS+kCmZ+6w+QaUdcljiheiBJA==} dev: false + /@types/prettier@2.7.3: + resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} + /@types/prismjs@1.26.3: resolution: {integrity: sha512-A0D0aTXvjlqJ5ZILMz3rNfDBOx9hHxLZYv2by47Sm/pqW35zzjusrZTryatjN/Rf8Us2gZrJD+KeHbUSTux1Cw==} dev: true @@ -12633,7 +13990,6 @@ packages: /@types/qs@6.9.11: resolution: {integrity: sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ==} - dev: false /@types/range-parser@1.2.7: resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==} @@ -12670,6 +14026,12 @@ packages: '@types/scheduler': 0.16.8 csstype: 3.1.3 + /@types/readable-stream@2.3.15: + resolution: {integrity: sha512-oM5JSKQCcICF1wvGgmecmHldZ48OZamtMxcGGVICOJA8o8cahXC1zEVAif8iwoc5j8etxFaRFnf095+CDsuoFQ==} + dependencies: + '@types/node': 20.10.6 + safe-buffer: 5.1.2 + /@types/resolve@1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: @@ -12679,6 +14041,11 @@ packages: /@types/scheduler@0.16.8: resolution: {integrity: sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==} + /@types/secp256k1@4.0.6: + resolution: {integrity: sha512-hHxJU6PAEUn0TP4S/ZOzuTUvJWuZ6eIKeNKb5RBpODvSl6hp1Wrw4s7ATY50rklRCScUDpHzVA/DQdSjJ3UoYQ==} + dependencies: + '@types/node': 20.10.6 + /@types/semver@6.2.7: resolution: {integrity: sha512-blctEWbzUFzQx799RZjzzIdBJOXmE37YYEyDtKkx5Dg+V7o/zyyAxLPiI98A2jdTtDgxZleMdfV+7p8WbRJ1OQ==} dev: true @@ -12785,7 +14152,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(eslint@8.55.0)(typescript@5.3.3) '@typescript-eslint/utils': 5.62.0(eslint@8.55.0)(typescript@5.3.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.55.0 graphemer: 1.4.0 ignore: 5.3.0 @@ -12810,7 +14177,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.3.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.55.0 typescript: 5.3.3 transitivePeerDependencies: @@ -12835,7 +14202,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.3.3) '@typescript-eslint/utils': 5.62.0(eslint@8.55.0)(typescript@5.3.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.55.0 tsutils: 3.21.0(typescript@5.3.3) typescript: 5.3.3 @@ -12858,7 +14225,7 @@ packages: dependencies: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/visitor-keys': 5.62.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -13399,6 +14766,48 @@ packages: /@ungap/structured-clone@1.2.0: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} + /@uniswap/hardhat-v3-deploy@0.1.1(hardhat@2.19.4): + resolution: {integrity: sha512-Qtwj1cNqCgzjtAonoU+morZnZuYCtiPi76ThnW9oYwHAlmcZ6y8jmlP7A2IzNzRaztaafC3bOamLmCNSyYqqpQ==} + peerDependencies: + hardhat: ^2.0.0 + dependencies: + '@uniswap/v3-core': 1.0.0 + '@uniswap/v3-periphery': 1.4.4 + cli-table3: 0.6.3 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + dev: false + + /@uniswap/lib@4.0.1-alpha: + resolution: {integrity: sha512-f6UIliwBbRsgVLxIaBANF6w09tYqc6Y/qXdsrbEmXHyFA7ILiKrIwRFXe1yOg8M3cksgVsO9N7yuL2DdCGQKBA==} + engines: {node: '>=10'} + dev: false + + /@uniswap/v2-core@1.0.1: + resolution: {integrity: sha512-MtybtkUPSyysqLY2U210NBDeCHX+ltHt3oADGdjqoThZaFRDKwM6k1Nb3F0A3hk5hwuQvytFWhrWHOEq6nVJ8Q==} + engines: {node: '>=10'} + dev: false + + /@uniswap/v3-core@1.0.0: + resolution: {integrity: sha512-kSC4djMGKMHj7sLMYVnn61k9nu+lHjMIxgg9CDQT+s2QYLoA56GbSK9Oxr+qJXzzygbkrmuY6cwgP6cW2JXPFA==} + engines: {node: '>=10'} + dev: false + + /@uniswap/v3-core@1.0.1: + resolution: {integrity: sha512-7pVk4hEm00j9tc71Y9+ssYpO6ytkeI0y7WE9P6UcmNzhxPePwyAxImuhVsTqWK9YFvzgtvzJHi64pBl4jUzKMQ==} + engines: {node: '>=10'} + dev: false + + /@uniswap/v3-periphery@1.4.4: + resolution: {integrity: sha512-S4+m+wh8HbWSO3DKk4LwUCPZJTpCugIsHrWR86m/OrUyvSqGDTXKFfc2sMuGXCZrD1ZqO3rhQsKgdWg3Hbb2Kw==} + engines: {node: '>=10'} + dependencies: + '@openzeppelin/contracts': 3.4.2-solc-0.7 + '@uniswap/lib': 4.0.1-alpha + '@uniswap/v2-core': 1.0.1 + '@uniswap/v3-core': 1.0.1 + base64-sol: 1.0.1 + dev: false + /@vercel/analytics@1.1.1: resolution: {integrity: sha512-+NqgNmSabg3IFfxYhrWCfB/H+RCUOCR5ExRudNG2+pcRehq628DJB5e1u1xqwpLtn4pAYii4D98w7kofORAGQA==} dependencies: @@ -13493,6 +14902,50 @@ packages: resolution: {integrity: sha512-7OjdcV8vQ74eiz1TZLzZP4JwqM5fA94K6yntPS5Z25r9HDuGNzaGdgvwKYq6S+MxwF0TFRwe50fIR/MYnakdkQ==} dev: false + /@wagmi/cli@1.5.2(typescript@5.3.3): + resolution: {integrity: sha512-UfLMYhW6mQBCjR8A5s01Chf9GpHzdpcuuBuzJ36QGXcMSJAxylz5ImVZWfCRV0ct1UruydjKVSW1QSI6azNxRQ==} + engines: {node: '>=14'} + hasBin: true + peerDependencies: + '@wagmi/core': '>=1.0.0' + typescript: '>=5.0.4' + wagmi: '>=1.0.0' + peerDependenciesMeta: + '@wagmi/core': + optional: true + typescript: + optional: true + wagmi: + optional: true + dependencies: + abitype: 0.8.7(typescript@5.3.3)(zod@3.22.4) + abort-controller: 3.0.0 + bundle-require: 3.1.2(esbuild@0.16.17) + cac: 6.7.14 + change-case: 4.1.2 + chokidar: 3.5.3 + dedent: 0.7.0 + detect-package-manager: 2.0.1 + dotenv: 16.3.2 + dotenv-expand: 10.0.0 + esbuild: 0.16.17 + execa: 6.1.0 + find-up: 6.3.0 + fs-extra: 10.1.0 + globby: 13.2.2 + node-fetch: 3.3.2 + ora: 6.3.1 + pathe: 1.1.2 + picocolors: 1.0.0 + prettier: 2.8.8 + typescript: 5.3.3 + viem: 1.19.11(typescript@5.3.3)(zod@3.22.4) + zod: 3.22.4 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + /@wagmi/connectors@3.1.6(@types/react@18.2.42)(react@18.2.0)(typescript@5.3.3)(viem@1.19.11)(zod@3.22.4): resolution: {integrity: sha512-71ZW9ETmzFJbetMfGAUEtJtTyDGetAT/pkdsMwyvH+MBPoZuqHUQ7NxgvhSo9ddsAzsEbJJLCaJdZodj3CbosA==} peerDependencies: @@ -14245,6 +15698,9 @@ packages: jsonparse: 1.3.1 through: 2.3.8 + /abbrev@1.0.9: + resolution: {integrity: sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==} + /abitype@0.8.7(typescript@5.3.3)(zod@3.22.4): resolution: {integrity: sha512-wQ7hV8Yg/yKmGyFpqrNZufCxbszDe5es4AZGYPBitocfSqXtjrTG9JMWFcc4N30ukl2ve48aBTwt7NJxVQdU3w==} peerDependencies: @@ -14271,6 +15727,12 @@ packages: dependencies: typescript: 5.3.3 zod: 3.22.4 + + /abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} + dependencies: + event-target-shim: 5.0.1 dev: false /abortcontroller-polyfill@1.7.5: @@ -14281,6 +15743,18 @@ packages: resolution: {integrity: sha512-d8XPSGjfyzlXC3Xx891DJRyZfqk5JU0BJrDQcsWomFIV1/BIzPW5HDH5iDdWpqWaav0YVIEzT1RHTwWr0FFshA==} dev: false + /abstract-level@1.0.4: + resolution: {integrity: sha512-eUP/6pbXBkMbXFdx4IH2fVgvB7M0JvR7/lIL33zcs0IBcwjdzSSl31TOJsaCzmKSSDF9h8QYSOJux4Nd4YJqFg==} + engines: {node: '>=12'} + dependencies: + buffer: 6.0.3 + catering: 2.1.1 + is-buffer: 2.0.5 + level-supports: 4.0.1 + level-transcoder: 1.0.1 + module-error: 1.0.2 + queue-microtask: 1.2.3 + /accepts@1.3.8: resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} engines: {node: '>= 0.6'} @@ -14313,19 +15787,41 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + /address@1.2.2: + resolution: {integrity: sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==} + engines: {node: '>= 10.0.0'} + /addressparser@1.0.1: resolution: {integrity: sha512-aQX7AISOMM7HFE0iZ3+YnD07oIeJqWGVnJ+ZIKaBZAk03ftmVYVqsGas/rbXKR21n4D/hKCSHypvcyOkds/xzg==} dev: false + /adm-zip@0.4.16: + resolution: {integrity: sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==} + engines: {node: '>=0.3.0'} + + /aes-js@3.0.0: + resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} + /aes-js@3.1.2: resolution: {integrity: sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==} dev: false + /aes-js@4.0.0-beta.5: + resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} + + /agent-base@6.0.2: + resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} + engines: {node: '>= 6.0.0'} + dependencies: + debug: 4.3.4(supports-color@8.1.1) + transitivePeerDependencies: + - supports-color + /agent-base@7.1.0: resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==} engines: {node: '>= 14'} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -14367,10 +15863,29 @@ packages: require-from-string: 2.0.2 uri-js: 4.4.1 + /amdefine@1.0.1: + resolution: {integrity: sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==} + engines: {node: '>=0.4.2'} + requiresBuild: true + optional: true + + /amp-message@0.1.2: + resolution: {integrity: sha512-JqutcFwoU1+jhv7ArgW38bqrE+LQdcRv4NxNw0mp0JHQyB6tXesWRjtYKlDgHRY2o3JE5UTaBGUK8kSWUdxWUg==} + dependencies: + amp: 0.3.1 + dev: true + + /amp@0.3.1: + resolution: {integrity: sha512-OwIuC4yZaRogHKiuU5WlMR5Xk/jAcpPtawWL05Gj8Lvm2F6mwoJt4O/bHI+DHwG79vWd+8OFYM4/BzYqyRd3qw==} + dev: true + + /ansi-colors@4.1.1: + resolution: {integrity: sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==} + engines: {node: '>=6'} + /ansi-colors@4.1.3: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} - dev: true /ansi-escapes@4.3.2: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} @@ -14385,6 +15900,10 @@ packages: type-fest: 1.4.0 dev: true + /ansi-regex@3.0.1: + resolution: {integrity: sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==} + engines: {node: '>=4'} + /ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -14413,6 +15932,9 @@ packages: resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} engines: {node: '>=12'} + /antlr4ts@0.5.0-alpha.4: + resolution: {integrity: sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==} + /any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} @@ -14454,6 +15976,14 @@ packages: dependencies: dequal: 2.0.3 + /array-back@3.1.0: + resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} + engines: {node: '>=6'} + + /array-back@4.0.2: + resolution: {integrity: sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==} + engines: {node: '>=8'} + /array-buffer-byte-length@1.0.0: resolution: {integrity: sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==} dependencies: @@ -14497,7 +16027,6 @@ packages: /array-uniq@1.0.3: resolution: {integrity: sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==} engines: {node: '>=0.10.0'} - dev: false /array.prototype.findlastindex@1.2.3: resolution: {integrity: sha512-LzLoiOMAxvy+Gd3BAq3B7VeIgPdo+Q8hthvKtXybMvRV0jrXfJM/t8mw7nNlpEcVlVUnCnM2KSX4XU5HmpodOA==} @@ -14553,6 +16082,12 @@ packages: engines: {node: '>=0.10.0'} dev: true + /asap@2.0.6: + resolution: {integrity: sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==} + + /assertion-error@1.1.0: + resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + /ast-types-flow@0.0.8: resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==} @@ -14565,22 +16100,37 @@ packages: /astral-regex@2.0.0: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} - dev: false /astring@1.8.6: resolution: {integrity: sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==} hasBin: true dev: false + /async-listener@0.6.10: + resolution: {integrity: sha512-gpuo6xOyF4D5DE5WvyqZdPA3NGhiT6Qf07l7DCB0wwDEsLvDIbCr6j9S5aj5Ch96dLace5tXVzWBZkxU/c5ohw==} + engines: {node: <=0.11.8 || >0.11.10} + dependencies: + semver: 5.7.2 + shimmer: 1.2.1 + dev: true + /async-mutex@0.2.6: resolution: {integrity: sha512-Hs4R+4SPgamu6rSGW8C7cV9gaWUKEHykfzCCvIRuaVv636Ju10ZdeUbvb4TBEW0INuq2DHZqXbK4Nd3yG4RaRw==} dependencies: tslib: 2.6.2 dev: false + /async@1.5.2: + resolution: {integrity: sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==} + + /async@2.6.4: + resolution: {integrity: sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==} + dependencies: + lodash: 4.17.21 + dev: true + /async@3.2.5: resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} - dev: false /asynciterator.prototype@1.0.0: resolution: {integrity: sha512-wwHYEIS0Q80f5mosx3L/dfG5t5rjEa9Ft51GTaNt862EnpyGHpgz2RkZvLPp1oF5TnAiTohkEKVEu8pQPJI7Vg==} @@ -14593,7 +16143,6 @@ packages: /at-least-node@1.0.0: resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} engines: {node: '>= 4.0.0'} - dev: false /atomic-sleep@1.0.0: resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} @@ -14629,10 +16178,18 @@ packages: resolution: {integrity: sha512-M0JtH+hlOL5pLQwHOLNYZaXuhqmvS8oExsqB1SBYgA4Dk7u/xx+YdGHXaK5pyUfed5mYXdlYiphWq3G8cRi5JQ==} engines: {node: '>=4'} + /axios@0.21.4(debug@4.3.4): + resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==} + dependencies: + follow-redirects: 1.15.5(debug@4.3.4) + transitivePeerDependencies: + - debug + dev: false + /axios@1.2.0: resolution: {integrity: sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==} dependencies: - follow-redirects: 1.15.5 + follow-redirects: 1.15.5(debug@4.3.4) form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -14642,12 +16199,11 @@ packages: /axios@1.6.5: resolution: {integrity: sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==} dependencies: - follow-redirects: 1.15.5 + follow-redirects: 1.15.5(debug@4.3.4) form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: - debug - dev: false /axobject-query@3.2.1: resolution: {integrity: sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==} @@ -14736,15 +16292,21 @@ packages: resolution: {integrity: sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==} dependencies: safe-buffer: 5.2.1 - dev: false /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + /base64-sol@1.0.1: + resolution: {integrity: sha512-ld3cCNMeXt4uJXmLZBHFGMvVpK9KsLVEhPpFRXnvSVAqABKbuNZg/+dsq3NuM+wxFLb/UrVkz7m1ciWmkMfTbg==} + dev: false + /basic-ftp@5.0.4: resolution: {integrity: sha512-8PzkB0arJFV4jJWSGOYR+OEic6aeKMu/osRhBULN6RY0ykby6LKhbmuQ5ublvaas5BOwboah5D87nrHyuh8PPA==} engines: {node: '>=10.0.0'} + /bech32@1.1.4: + resolution: {integrity: sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==} + /before-after-hook@2.2.3: resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} dev: false @@ -14773,6 +16335,10 @@ packages: bindings: 1.5.0 dev: false + /bigint-crypto-utils@3.3.0: + resolution: {integrity: sha512-jOTSb+drvEDxEq6OuUybOAv/xxoh3cuYRUIPyu8sSHQNKM303UQ2R1DAo45o1AkcIXw6fzbaFI1+xGGdaXs2lg==} + engines: {node: '>=14.0.0'} + /binary-extensions@2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} @@ -14794,13 +16360,39 @@ packages: inherits: 2.0.4 readable-stream: 3.6.2 + /bl@5.1.0: + resolution: {integrity: sha512-tv1ZJHLfTDnXE6tMHv73YgSJaWR2AFuPwMntBe7XL/GBFHnT0CLnsHMogfk5+GzCDC5ZWarSCYaIGATZt9dNsQ==} + dependencies: + buffer: 6.0.3 + inherits: 2.0.4 + readable-stream: 3.6.2 + dev: false + + /blakejs@1.2.1: + resolution: {integrity: sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==} + + /blessed@0.1.81: + resolution: {integrity: sha512-LoF5gae+hlmfORcG1M5+5XZi4LBmvlXTzwJWzUlPryN/SJdSflZvROM2TwkT0GMpq7oqT48NRd4GS7BiVBc5OQ==} + engines: {node: '>= 0.8.0'} + hasBin: true + dev: true + /bluebird@3.7.2: resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==} dev: false + /bn.js@4.11.6: + resolution: {integrity: sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA==} + + /bn.js@4.12.0: + resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} + /bn.js@5.2.1: resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} - dev: false + + /bodec@0.1.0: + resolution: {integrity: sha512-Ylo+MAo5BDUq1KA3f3R/MFhh+g8cnHmo8bz3YPGhI1znrMaf77ol1sfvYJzsw3nTE+Y2GryfDxBaR+AqpAkEHQ==} + dev: true /body-parser@1.20.1: resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==} @@ -14860,12 +16452,36 @@ packages: wcwidth: 1.0.1 dev: true + /brorand@1.1.0: + resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} + /brotli@1.3.3: resolution: {integrity: sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==} dependencies: base64-js: 1.5.1 dev: false + /browser-level@1.0.1: + resolution: {integrity: sha512-XECYKJ+Dbzw0lbydyQuJzwNXtOpbMSq737qxJN11sIRTErOMShvDpbzTlgju7orJKvx4epULolZAuJGLzCmWRQ==} + dependencies: + abstract-level: 1.0.4 + catering: 2.1.1 + module-error: 1.0.2 + run-parallel-limit: 1.1.0 + + /browser-stdout@1.3.1: + resolution: {integrity: sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==} + + /browserify-aes@1.2.0: + resolution: {integrity: sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==} + dependencies: + buffer-xor: 1.0.3 + cipher-base: 1.0.4 + create-hash: 1.2.0 + evp_bytestokey: 1.0.3 + inherits: 2.0.4 + safe-buffer: 5.2.1 + /browserify-zlib@0.2.0: resolution: {integrity: sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==} dependencies: @@ -14897,7 +16513,13 @@ packages: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} dependencies: base-x: 3.0.9 - dev: false + + /bs58check@2.1.2: + resolution: {integrity: sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==} + dependencies: + bs58: 4.0.1 + create-hash: 1.2.0 + safe-buffer: 5.2.1 /btoa-lite@1.0.0: resolution: {integrity: sha512-gvW7InbIyF8AicrqWoptdW08pUxuhq8BEgowNajy9RhiE86fmGAGl+bLKo6oB8QP0CkqHLowfN0oJdKC/J6LbA==} @@ -14914,6 +16536,9 @@ packages: /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + /buffer-xor@1.0.3: + resolution: {integrity: sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==} + /buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} dependencies: @@ -14925,7 +16550,6 @@ packages: dependencies: base64-js: 1.5.1 ieee754: 1.2.1 - dev: false /bufferutil@4.0.8: resolution: {integrity: sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==} @@ -14935,6 +16559,11 @@ packages: node-gyp-build: 4.8.0 dev: false + /bufio@1.2.1: + resolution: {integrity: sha512-9oR3zNdupcg/Ge2sSHQF3GX+kmvL/fTPvD0nd5AGLq8SjUYnTz+SlFjK/GXidndbZtIj+pVKXiWeR9w6e9wKCA==} + engines: {node: '>=14.0.0'} + dev: false + /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} @@ -14946,6 +16575,16 @@ packages: semver: 7.5.4 dev: true + /bundle-require@3.1.2(esbuild@0.16.17): + resolution: {integrity: sha512-Of6l6JBAxiyQ5axFxUM6dYeP/W7X2Sozeo/4EYB9sJhL+dqL7TKjg+shwxp6jlu/6ZSERfsYtIpSJ1/x3XkAEA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + peerDependencies: + esbuild: '>=0.13' + dependencies: + esbuild: 0.16.17 + load-tsconfig: 0.2.5 + dev: false + /bundle-require@4.0.2(esbuild@0.18.20): resolution: {integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -14965,7 +16604,6 @@ packages: /bytes@3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - dev: false /cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} @@ -15007,6 +16645,13 @@ packages: upper-case: 1.1.3 dev: true + /camel-case@4.1.2: + resolution: {integrity: sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==} + dependencies: + pascal-case: 3.1.2 + tslib: 2.6.2 + dev: false + /camelcase-keys@6.2.2: resolution: {integrity: sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==} engines: {node: '>=8'} @@ -15035,10 +16680,55 @@ packages: resolution: {integrity: sha512-+VsMpRr64jYgKq2IeFUNel3vCZH/IzS+iXSHxmUV3IUH5dXlC9xHz4AwtPZisDxZ5MWcuK0V+TXgPKFPiZnxzg==} dev: false + /capital-case@1.0.4: + resolution: {integrity: sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==} + dependencies: + no-case: 3.0.4 + tslib: 2.6.2 + upper-case-first: 2.0.2 + dev: false + + /case@1.6.3: + resolution: {integrity: sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ==} + engines: {node: '>= 0.8.0'} + + /caseless@0.12.0: + resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==} + + /catering@2.1.1: + resolution: {integrity: sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==} + engines: {node: '>=6'} + + /cbor@8.1.0: + resolution: {integrity: sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg==} + engines: {node: '>=12.19'} + dependencies: + nofilter: 3.1.0 + /ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} dev: false + /chai-as-promised@7.1.1(chai@4.4.1): + resolution: {integrity: sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==} + peerDependencies: + chai: '>= 2.1.2 < 5' + dependencies: + chai: 4.4.1 + check-error: 1.0.3 + + /chai@4.4.1: + resolution: {integrity: sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==} + engines: {node: '>=4'} + dependencies: + assertion-error: 1.1.0 + check-error: 1.0.3 + deep-eql: 4.1.3 + get-func-name: 2.0.2 + loupe: 2.3.7 + pathval: 1.1.1 + type-detect: 4.0.8 + /chalk@2.3.0: resolution: {integrity: sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==} engines: {node: '>=4'} @@ -15098,6 +16788,23 @@ packages: upper-case-first: 1.1.2 dev: true + /change-case@4.1.2: + resolution: {integrity: sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==} + dependencies: + camel-case: 4.1.2 + capital-case: 1.0.4 + constant-case: 3.0.4 + dot-case: 3.0.4 + header-case: 2.0.4 + no-case: 3.0.4 + param-case: 3.0.4 + pascal-case: 3.1.2 + path-case: 3.0.4 + sentence-case: 3.0.4 + snake-case: 3.0.4 + tslib: 2.6.2 + dev: false + /change-case@5.1.2: resolution: {integrity: sha512-CAtbGEDulyjzs05RXy3uKcwqeztz/dMEuAc1Xu9NQBsbrhuGMneL0u9Dj5SoutLKBFYun8txxYIwhjtLNfUmCA==} dev: false @@ -15121,6 +16828,18 @@ packages: /chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + /charenc@0.0.2: + resolution: {integrity: sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==} + + /charm@0.1.2: + resolution: {integrity: sha512-syedaZ9cPe7r3hoQA9twWYKu5AIyCswN5+szkmPBe9ccdLrj4bYaCnLVPTLd2kgVRc7+zoX4tyPgRnFKCj5YjQ==} + dev: true + + /check-error@1.0.3: + resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} + dependencies: + get-func-name: 2.0.2 + /chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} @@ -15156,13 +16875,18 @@ packages: /ci-info@2.0.0: resolution: {integrity: sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==} - dev: false /ci-info@3.9.0: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} dev: true + /cipher-base@1.0.4: + resolution: {integrity: sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==} + dependencies: + inherits: 2.0.4 + safe-buffer: 5.2.1 + /citty@0.1.5: resolution: {integrity: sha512-AS7n5NSc0OQVMV9v6wt3ByujNIrne0/cTjiC2MYqhvao57VNfiuVksTSr2p17nVOhEr2KtqiAkGwHcgMC/qUuQ==} dependencies: @@ -15179,6 +16903,17 @@ packages: clsx: 2.0.0 dev: false + /classic-level@1.4.1: + resolution: {integrity: sha512-qGx/KJl3bvtOHrGau2WklEZuXhS3zme+jf+fsu6Ej7W7IP/C49v7KNlWIsT1jZu0YnfzSIYDGcEWpCa1wKGWXQ==} + engines: {node: '>=12'} + requiresBuild: true + dependencies: + abstract-level: 1.0.4 + catering: 2.1.1 + module-error: 1.0.2 + napi-macros: 2.2.2 + node-gyp-build: 4.8.0 + /classnames@2.3.2: resolution: {integrity: sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==} dev: false @@ -15213,12 +16948,36 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dependencies: restore-cursor: 4.0.0 - dev: true /cli-spinners@2.9.2: resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==} engines: {node: '>=6'} + /cli-table3@0.5.1: + resolution: {integrity: sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==} + engines: {node: '>=6'} + dependencies: + object-assign: 4.1.1 + string-width: 2.1.1 + optionalDependencies: + colors: 1.4.0 + + /cli-table3@0.6.3: + resolution: {integrity: sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==} + engines: {node: 10.* || >= 12.*} + dependencies: + string-width: 4.2.3 + optionalDependencies: + '@colors/colors': 1.5.0 + dev: false + + /cli-tableau@2.0.1: + resolution: {integrity: sha512-he+WTicka9cl0Fg/y+YyxcN6/bfQ/1O3QmgxRXDhABKqLzvoOSM4fMzp39uMyLBulAFuywD2N7UaoQE7WaADxQ==} + engines: {node: '>=8.10.0'} + dependencies: + chalk: 3.0.0 + dev: true + /cli-truncate@2.1.0: resolution: {integrity: sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg==} engines: {node: '>=8'} @@ -15272,6 +17031,13 @@ packages: strip-ansi: 6.0.1 wrap-ansi: 6.2.0 + /cliui@7.0.4: + resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + /cliui@8.0.1: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} @@ -15357,6 +17123,10 @@ packages: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} dev: true + /colors@1.4.0: + resolution: {integrity: sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==} + engines: {node: '>=0.1.90'} + /combined-stream@1.0.8: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} engines: {node: '>= 0.8'} @@ -15367,6 +17137,27 @@ packages: resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} dev: false + /command-exists@1.2.9: + resolution: {integrity: sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==} + + /command-line-args@5.2.1: + resolution: {integrity: sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==} + engines: {node: '>=4.0.0'} + dependencies: + array-back: 3.1.0 + find-replace: 3.0.0 + lodash.camelcase: 4.3.0 + typical: 4.0.0 + + /command-line-usage@6.1.3: + resolution: {integrity: sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==} + engines: {node: '>=8.0.0'} + dependencies: + array-back: 4.0.2 + chalk: 2.4.2 + table-layout: 1.0.2 + typical: 5.2.0 + /commander@10.0.1: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} @@ -15377,10 +17168,17 @@ packages: engines: {node: '>=16'} dev: true + /commander@2.15.1: + resolution: {integrity: sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==} + dev: true + /commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} dev: false + /commander@3.0.2: + resolution: {integrity: sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==} + /commander@4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} @@ -15410,6 +17208,10 @@ packages: dot-prop: 5.3.0 dev: true + /complex.js@2.1.1: + resolution: {integrity: sha512-8njCHOTtFFLtegk6zQo0kkVX1rngygb/KQI6z1qZxlFI3scluC+LVTCFbrkWjBv4vvLlbQ9t88IPMC6k95VTTg==} + dev: true + /compute-scroll-into-view@1.0.20: resolution: {integrity: sha512-UCB0ioiyj8CRjtrvaceBLqqhZCVP+1B8+NWQhmdsm0VXOJtobBCf1dBQmebCCo34qZmUwZfIH2MZLqNHazrfjg==} dev: false @@ -15421,6 +17223,15 @@ packages: /concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + /concat-stream@1.6.2: + resolution: {integrity: sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==} + engines: {'0': node >= 0.8} + dependencies: + buffer-from: 1.1.2 + inherits: 2.0.4 + readable-stream: 2.3.8 + typedarray: 0.0.6 + /config-chain@1.1.13: resolution: {integrity: sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==} dependencies: @@ -15440,6 +17251,14 @@ packages: upper-case: 1.1.3 dev: true + /constant-case@3.0.4: + resolution: {integrity: sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==} + dependencies: + no-case: 3.0.4 + tslib: 2.6.2 + upper-case: 2.0.2 + dev: false + /content-disposition@0.5.4: resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==} engines: {node: '>= 0.6'} @@ -15457,6 +17276,13 @@ packages: engines: {node: '>= 0.6'} dev: false + /continuation-local-storage@3.2.1: + resolution: {integrity: sha512-jx44cconVqkCEEyLSKWwkvUXwO561jXMa3LPjTPsm5QR22PA0/mhe33FT4Xb5y74JDvt/Cq+5lm8S8rskLv9ZA==} + dependencies: + async-listener: 0.6.10 + emitter-listener: 1.1.2 + dev: true + /conventional-changelog-angular@6.0.0: resolution: {integrity: sha512-6qLgrBF4gueoC7AFVHu51nHL9pF9FRjXrH+ceVf7WmAfH3gs+gEYOkvxhjMPjZu57I4AGUGoNTY8V7Hrgf1uqg==} engines: {node: '>=14'} @@ -15501,7 +17327,6 @@ packages: /cookie@0.4.2: resolution: {integrity: sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==} engines: {node: '>= 0.6'} - dev: false /cookie@0.5.0: resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} @@ -15545,6 +17370,9 @@ packages: requiresBuild: true dev: true + /core-util-is@1.0.3: + resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + /cors@2.8.5: resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==} engines: {node: '>= 0.10'} @@ -15622,9 +17450,45 @@ packages: typescript: 5.3.3 dev: true + /crc-32@1.2.2: + resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} + engines: {node: '>=0.8'} + hasBin: true + + /create-hash@1.2.0: + resolution: {integrity: sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==} + dependencies: + cipher-base: 1.0.4 + inherits: 2.0.4 + md5.js: 1.3.5 + ripemd160: 2.0.2 + sha.js: 2.4.11 + + /create-hmac@1.1.7: + resolution: {integrity: sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==} + dependencies: + cipher-base: 1.0.4 + create-hash: 1.2.0 + inherits: 2.0.4 + ripemd160: 2.0.2 + safe-buffer: 5.2.1 + sha.js: 2.4.11 + /create-require@1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + /croner@4.1.97: + resolution: {integrity: sha512-/f6gpQuxDaqXu+1kwQYSckUglPaOrHdbIlBAu0YuW8/Cdb45XwXYNUBXg3r/9Mo6n540Kn/smKcZWko5x99KrQ==} + dev: true + + /cross-env@7.0.3: + resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} + engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} + hasBin: true + dependencies: + cross-spawn: 7.0.3 + dev: false + /cross-fetch@3.1.8: resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==} dependencies: @@ -15656,6 +17520,9 @@ packages: shebang-command: 2.0.0 which: 2.0.2 + /crypt@0.0.2: + resolution: {integrity: sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==} + /crypto-js@4.2.0: resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==} dev: false @@ -15761,6 +17628,10 @@ packages: stream-transform: 2.1.3 dev: true + /culvert@0.1.2: + resolution: {integrity: sha512-yi1x3EAWKjQTreYWeSd98431AV+IEE0qoDyOoaHJ7KJ21gv6HtBXHVLX74opVSGqcR8/AbjJBHAHpcOy2bj5Gg==} + dev: true + /cytoscape-cose-bilkent@4.1.0(cytoscape@3.28.1): resolution: {integrity: sha512-wgQlVIUJF13Quxiv5e1gstZ08rnZj2XaLHGoFMYXz7SkNfCDOOteKBE6SYRfA9WxxI/iBc3ajfDoc6hb/MRAHQ==} peerDependencies: @@ -16073,6 +17944,11 @@ packages: engines: {node: '>=8'} dev: true + /data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + dev: false + /data-uri-to-buffer@6.0.1: resolution: {integrity: sha512-MZd3VlchQkp8rdend6vrx7MmVDJzSNTBvghvKjirLkD+WTChA3KUf0jkE68Q4UyctNqI11zZO9/x2Yx+ub5Cvg==} engines: {node: '>= 14'} @@ -16085,7 +17961,13 @@ packages: /dayjs@1.11.10: resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==} - dev: false + + /dayjs@1.8.36: + resolution: {integrity: sha512-3VmRXEtw7RZKAf+4Tv1Ym9AGeo8r8+CjDi26x+7SYQil1UqtqdaokhzoEJohqlzt0m5kacJSDhJQkG/LWhpRBw==} + dev: true + + /death@1.1.0: + resolution: {integrity: sha512-vsV6S4KVHvTGxbEcij7hkWRv0It+sGGWVOM67dQde/o5Xjnr+KmLjxWJii2uEObIrt1CcM9w0Yaovx+iOlIL+w==} /debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} @@ -16108,7 +17990,7 @@ packages: dependencies: ms: 2.1.3 - /debug@4.3.4: + /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} peerDependencies: @@ -16118,6 +18000,7 @@ packages: optional: true dependencies: ms: 2.1.2 + supports-color: 8.1.1 /decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} @@ -16131,6 +18014,14 @@ packages: resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==} engines: {node: '>=0.10.0'} + /decamelize@4.0.0: + resolution: {integrity: sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==} + engines: {node: '>=10'} + + /decimal.js@10.4.3: + resolution: {integrity: sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==} + dev: true + /decode-named-character-reference@1.0.2: resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==} dependencies: @@ -16154,6 +18045,16 @@ packages: mimic-response: 3.1.0 dev: false + /dedent@0.7.0: + resolution: {integrity: sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==} + dev: false + + /deep-eql@4.1.3: + resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} + engines: {node: '>=6'} + dependencies: + type-detect: 4.0.8 + /deep-extend@0.6.0: resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} engines: {node: '>=4.0.0'} @@ -16258,7 +18159,6 @@ packages: /depd@2.0.0: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} - dev: false /deprecation@2.3.1: resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} @@ -16301,6 +18201,22 @@ packages: resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==} dev: false + /detect-package-manager@2.0.1: + resolution: {integrity: sha512-j/lJHyoLlWi6G1LDdLgvUtz60Zo5GEj+sVYtTVXnYLDPuzgC3llMxonXym9zIwhhUII8vjdw0LXxavpLqTbl1A==} + engines: {node: '>=12'} + dependencies: + execa: 5.1.1 + dev: false + + /detect-port@1.5.1: + resolution: {integrity: sha512-aBzdj76lueB6uUst5iAs7+0H/oOjqI5D16XUWxlWMIMROhcM0rfsNVk93zTngq1dDNpoXRr++Sus7ETAExppAQ==} + hasBin: true + dependencies: + address: 1.2.2 + debug: 4.3.4(supports-color@8.1.1) + transitivePeerDependencies: + - supports-color + /devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} dependencies: @@ -16340,11 +18256,20 @@ packages: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} + /diff@5.0.0: + resolution: {integrity: sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==} + engines: {node: '>=0.3.1'} + /diff@5.1.0: resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} engines: {node: '>=0.3.1'} dev: false + /difflib@0.2.4: + resolution: {integrity: sha512-9YVwmMb0wQHQNr5J9m6BSj6fk4pfGITGQOOs+D9Fl+INODWFOfvhIU1hNv6GgR1RBoC/9NJcwu77zShxV0kT7w==} + dependencies: + heap: 0.2.7 + /dijkstrajs@1.0.3: resolution: {integrity: sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==} dev: false @@ -16437,7 +18362,6 @@ packages: dependencies: no-case: 3.0.4 tslib: 2.6.2 - dev: true /dot-prop@5.3.0: resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} @@ -16477,7 +18401,6 @@ packages: /dotenv@16.3.2: resolution: {integrity: sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==} engines: {node: '>=12'} - dev: true /dotenv@7.0.0: resolution: {integrity: sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g==} @@ -16534,6 +18457,23 @@ packages: resolution: {integrity: sha512-JWKDyqAdltuUcyxaECtYG6H4sqysXSLeoXuGUBfRNESMTkj+w+qdb0jya8Z/WI0jVd03WQtCGhS6FOFtlhD5FQ==} dev: false + /elliptic@6.5.4: + resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} + dependencies: + bn.js: 4.12.0 + brorand: 1.1.0 + hash.js: 1.1.7 + hmac-drbg: 1.0.1 + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + + /emitter-listener@1.1.2: + resolution: {integrity: sha512-Bt1sBAGFHY9DKY+4/2cV6izcKJUf5T7/gkdmkxzX/qv9CcGH8xSwVRW5mtX03SWJtRTWSOpzCuWN9rBFYZepZQ==} + dependencies: + shimmer: 1.2.1 + dev: true + /emoji-mart@5.5.2: resolution: {integrity: sha512-Sqc/nso4cjxhOwWJsp9xkVm8OF5c+mJLZJFoFfzRuKO+yWiN7K8c96xmtughYb0d/fZ8UC6cLIQ/p4BR6Pv3/A==} dev: false @@ -16584,13 +18524,19 @@ packages: graceful-fs: 4.2.11 tapable: 2.2.1 + /enquirer@2.3.6: + resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} + engines: {node: '>=8.6'} + dependencies: + ansi-colors: 4.1.3 + dev: true + /enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} dependencies: ansi-colors: 4.1.3 strip-ansi: 6.0.1 - dev: true /entities@2.2.0: resolution: {integrity: sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==} @@ -16605,6 +18551,10 @@ packages: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} + /env-paths@2.2.1: + resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} + engines: {node: '>=6'} + /errno@0.1.8: resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==} hasBin: true @@ -16716,6 +18666,36 @@ packages: es6-promise: 4.2.8 dev: false + /esbuild@0.16.17: + resolution: {integrity: sha512-G8LEkV0XzDMNwXKgM0Jwu3nY3lSTwSGY6XbxM9cr9+s0T/qSV1q1JVPBGzm3dcjhCic9+emZDmMffkwgPeOeLg==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.16.17 + '@esbuild/android-arm64': 0.16.17 + '@esbuild/android-x64': 0.16.17 + '@esbuild/darwin-arm64': 0.16.17 + '@esbuild/darwin-x64': 0.16.17 + '@esbuild/freebsd-arm64': 0.16.17 + '@esbuild/freebsd-x64': 0.16.17 + '@esbuild/linux-arm': 0.16.17 + '@esbuild/linux-arm64': 0.16.17 + '@esbuild/linux-ia32': 0.16.17 + '@esbuild/linux-loong64': 0.16.17 + '@esbuild/linux-mips64el': 0.16.17 + '@esbuild/linux-ppc64': 0.16.17 + '@esbuild/linux-riscv64': 0.16.17 + '@esbuild/linux-s390x': 0.16.17 + '@esbuild/linux-x64': 0.16.17 + '@esbuild/netbsd-x64': 0.16.17 + '@esbuild/openbsd-x64': 0.16.17 + '@esbuild/sunos-x64': 0.16.17 + '@esbuild/win32-arm64': 0.16.17 + '@esbuild/win32-ia32': 0.16.17 + '@esbuild/win32-x64': 0.16.17 + dev: false + /esbuild@0.18.20: resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} engines: {node: '>=12'} @@ -16753,6 +18733,10 @@ packages: resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} dev: false + /escape-latex@1.2.0: + resolution: {integrity: sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw==} + dev: true + /escape-string-regexp@1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} @@ -16770,6 +18754,18 @@ packages: resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==} engines: {node: '>=12'} + /escodegen@1.8.1: + resolution: {integrity: sha512-yhi5S+mNTOuRvyW4gWlg5W1byMaQGWWSYHXsuFZ7GBo7tpyOwi2EdzMP/QWxh9hwkD2m+wDVHJsxhRIj+v/b/A==} + engines: {node: '>=0.12.0'} + hasBin: true + dependencies: + esprima: 2.7.3 + estraverse: 1.9.3 + esutils: 2.0.3 + optionator: 0.8.3 + optionalDependencies: + source-map: 0.2.0 + /escodegen@2.1.0: resolution: {integrity: sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==} engines: {node: '>=6.0'} @@ -16796,7 +18792,7 @@ packages: eslint: 8.55.0 eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.55.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@5.62.0)(eslint@8.55.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.55.0) eslint-plugin-jsx-a11y: 6.8.0(eslint@8.55.0) eslint-plugin-react: 7.33.2(eslint@8.55.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.55.0) @@ -16865,7 +18861,7 @@ packages: eslint: '*' eslint-plugin-import: '*' dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) enhanced-resolve: 5.15.0 eslint: 8.55.0 eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.55.0) @@ -16943,41 +18939,6 @@ packages: - eslint-import-resolver-webpack - supports-color - /eslint-plugin-import@2.29.1(@typescript-eslint/parser@5.62.0)(eslint@8.55.0): - resolution: {integrity: sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==} - engines: {node: '>=4'} - peerDependencies: - '@typescript-eslint/parser': '*' - eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 - peerDependenciesMeta: - '@typescript-eslint/parser': - optional: true - dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.55.0)(typescript@5.3.3) - array-includes: 3.1.7 - array.prototype.findlastindex: 1.2.3 - array.prototype.flat: 1.3.2 - array.prototype.flatmap: 1.3.2 - debug: 3.2.7 - doctrine: 2.1.0 - eslint: 8.55.0 - eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.55.0) - hasown: 2.0.0 - is-core-module: 2.13.1 - is-glob: 4.0.3 - minimatch: 3.1.2 - object.fromentries: 2.0.7 - object.groupby: 1.0.1 - object.values: 1.1.7 - semver: 6.3.1 - tsconfig-paths: 3.15.0 - transitivePeerDependencies: - - eslint-import-resolver-typescript - - eslint-import-resolver-webpack - - supports-color - dev: false - /eslint-plugin-jsx-a11y@6.8.0(eslint@8.55.0): resolution: {integrity: sha512-Hdh937BS3KdwwbBaKd5+PLCOmYY6U4f2h9Z2ktwtNKvIdIEu137rjYbcb9ApSbVJfWxANNuiKTD/9tOKjK9qOA==} engines: {node: '>=4.0'} @@ -17102,7 +19063,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -17140,6 +19101,11 @@ packages: acorn-jsx: 5.3.2(acorn@8.11.3) eslint-visitor-keys: 3.4.3 + /esprima@2.7.3: + resolution: {integrity: sha512-OarPfz0lFCiW4/AV2Oy1Rp9qu0iusTKqykwTspGCZtPxmF81JR4MmIebvF1F9+UOKth2ZubLQ4XGGaU+hSn99A==} + engines: {node: '>=0.10.0'} + hasBin: true + /esprima@4.0.1: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} engines: {node: '>=4'} @@ -17157,6 +19123,10 @@ packages: dependencies: estraverse: 5.3.0 + /estraverse@1.9.3: + resolution: {integrity: sha512-25w1fMXQrGdoquWnScXZGckOv+Wes+JDnuN/+7ex3SauFRS72r2lFDec0EKPt2YD1wUJ/IrfEex+9yp4hfSOJA==} + engines: {node: '>=0.10.0'} + /estraverse@4.3.0: resolution: {integrity: sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==} engines: {node: '>=4.0'} @@ -17241,6 +19211,32 @@ packages: - supports-color dev: false + /eth-gas-reporter@0.2.27: + resolution: {integrity: sha512-femhvoAM7wL0GcI8ozTdxfuBtBFJ9qsyIAsmKVjlWAHUbdnnXHt+lKzz/kmldM5lA9jLuNHGwuIxorNpLbR1Zw==} + peerDependencies: + '@codechecks/client': ^0.1.0 + peerDependenciesMeta: + '@codechecks/client': + optional: true + dependencies: + '@solidity-parser/parser': 0.14.5 + axios: 1.6.5 + cli-table3: 0.5.1 + colors: 1.4.0 + ethereum-cryptography: 1.2.0 + ethers: 5.7.2 + fs-readdir-recursive: 1.1.0 + lodash: 4.17.21 + markdown-table: 1.1.3 + mocha: 10.2.0 + req-cwd: 2.0.0 + sha1: 1.1.1 + sync-request: 6.1.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + /eth-json-rpc-filters@5.1.0: resolution: {integrity: sha512-fos+9xmoa1A2Ytsc9eYof17r81BjdJOUcGcgZn4K/tKdCCTb+a8ytEtwlu1op5qsXFDlgGmstTELFrDEc89qEQ==} engines: {node: '>=14.0.0'} @@ -17265,6 +19261,156 @@ packages: fast-safe-stringify: 2.1.1 dev: false + /ethereum-bloom-filters@1.0.10: + resolution: {integrity: sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA==} + dependencies: + js-sha3: 0.8.0 + + /ethereum-cryptography@0.1.3: + resolution: {integrity: sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==} + dependencies: + '@types/pbkdf2': 3.1.2 + '@types/secp256k1': 4.0.6 + blakejs: 1.2.1 + browserify-aes: 1.2.0 + bs58check: 2.1.2 + create-hash: 1.2.0 + create-hmac: 1.1.7 + hash.js: 1.1.7 + keccak: 3.0.4 + pbkdf2: 3.1.2 + randombytes: 2.1.0 + safe-buffer: 5.2.1 + scrypt-js: 3.0.1 + secp256k1: 4.0.3 + setimmediate: 1.0.5 + + /ethereum-cryptography@1.2.0: + resolution: {integrity: sha512-6yFQC9b5ug6/17CQpCyE3k9eKBMdhyVjzUy1WkiuY/E4vj/SXDBbCw8QEIaXqf0Mf2SnY6RmpDcwlUmBSS0EJw==} + dependencies: + '@noble/hashes': 1.2.0 + '@noble/secp256k1': 1.7.1 + '@scure/bip32': 1.1.5 + '@scure/bip39': 1.1.1 + + /ethereum-cryptography@2.1.3: + resolution: {integrity: sha512-BlwbIL7/P45W8FGW2r7LGuvoEZ+7PWsniMvQ4p5s2xCyw9tmaDlpfsN9HjAucbF+t/qpVHwZUisgfK24TCW8aA==} + dependencies: + '@noble/curves': 1.3.0 + '@noble/hashes': 1.3.3 + '@scure/bip32': 1.3.3 + '@scure/bip39': 1.2.2 + + /ethereumjs-abi@0.6.8: + resolution: {integrity: sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==} + dependencies: + bn.js: 4.12.0 + ethereumjs-util: 6.2.1 + + /ethereumjs-util@6.2.1: + resolution: {integrity: sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==} + dependencies: + '@types/bn.js': 4.11.6 + bn.js: 4.12.0 + create-hash: 1.2.0 + elliptic: 6.5.4 + ethereum-cryptography: 0.1.3 + ethjs-util: 0.1.6 + rlp: 2.2.7 + + /ethereumjs-util@7.1.5: + resolution: {integrity: sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==} + engines: {node: '>=10.0.0'} + dependencies: + '@types/bn.js': 5.1.5 + bn.js: 5.2.1 + create-hash: 1.2.0 + ethereum-cryptography: 0.1.3 + rlp: 2.2.7 + + /ethers@5.7.2: + resolution: {integrity: sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/json-wallets': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/providers': 5.7.2 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/solidity': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/units': 5.7.0 + '@ethersproject/wallet': 5.7.0 + '@ethersproject/web': 5.7.1 + '@ethersproject/wordlists': 5.7.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /ethers@6.10.0: + resolution: {integrity: sha512-nMNwYHzs6V1FR3Y4cdfxSQmNgZsRj1RiTU25JwvnJLmyzw9z3SKxNc2XKDuiXXo/v9ds5Mp9m6HBabgYQQ26tA==} + engines: {node: '>=14.0.0'} + dependencies: + '@adraffy/ens-normalize': 1.10.0 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@types/node': 18.15.13 + aes-js: 4.0.0-beta.5 + tslib: 2.4.0 + ws: 8.5.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /ethjs-unit@0.1.6: + resolution: {integrity: sha512-/Sn9Y0oKl0uqQuvgFk/zQgR7aw1g36qX/jzSQ5lSwlO0GigPymk4eGQfeNTD03w1dPOqfz8V77Cy43jH56pagw==} + engines: {node: '>=6.5.0', npm: '>=3'} + dependencies: + bn.js: 4.11.6 + number-to-bn: 1.7.0 + + /ethjs-util@0.1.6: + resolution: {integrity: sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==} + engines: {node: '>=6.5.0', npm: '>=3'} + dependencies: + is-hex-prefixed: 1.0.0 + strip-hex-prefix: 1.0.0 + + /event-target-shim@5.0.1: + resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} + engines: {node: '>=6'} + dev: false + + /eventemitter2@0.4.14: + resolution: {integrity: sha512-K7J4xq5xAD5jHsGM5ReWXRTFa3JRGofHiMcVgQ8PRwgWxzjHpMWCIzsmyf60+mh8KLsqYPcjUMa0AC4hd6lPyQ==} + dev: true + + /eventemitter2@5.0.1: + resolution: {integrity: sha512-5EM1GHXycJBS6mauYAbVKT1cVs7POKWb2NXD4Vyt8dDqeZa7LaDK1/sjtL+Zb0lzTpSNil4596Dyu97hz37QLg==} + dev: true + + /eventemitter2@6.4.9: + resolution: {integrity: sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==} + dev: true + /eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: false @@ -17278,6 +19424,12 @@ packages: engines: {node: '>=0.8.x'} dev: false + /evp_bytestokey@1.0.3: + resolution: {integrity: sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==} + dependencies: + md5.js: 1.3.5 + safe-buffer: 5.2.1 + /execa@0.8.0: resolution: {integrity: sha512-zDWS+Rb1E8BlqqhALSt9kUhss8Qq4nN3iof3gsOdyINksElaPyNBtKUMTR62qhvgVWR0CqCX7sdnKe4MnUbFEA==} engines: {node: '>=4'} @@ -17305,6 +19457,21 @@ packages: signal-exit: 3.0.7 strip-final-newline: 2.0.0 + /execa@6.1.0: + resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + cross-spawn: 7.0.3 + get-stream: 6.0.1 + human-signals: 3.0.1 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.2.0 + onetime: 6.0.0 + signal-exit: 3.0.7 + strip-final-newline: 3.0.0 + dev: false + /execa@7.2.0: resolution: {integrity: sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==} engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} @@ -17407,7 +19574,7 @@ packages: engines: {node: '>= 10.17.0'} hasBin: true dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) get-stream: 5.2.0 yauzl: 2.10.0 optionalDependencies: @@ -17416,6 +19583,14 @@ packages: - supports-color dev: false + /extrareqp2@1.0.0(debug@4.3.4): + resolution: {integrity: sha512-Gum0g1QYb6wpPJCVypWP3bbIuaibcFiJcpuPM10YSXp/tzqi84x9PJageob+eN4xVRIOto4wjSGNLyMD54D2xA==} + dependencies: + follow-redirects: 1.15.5(debug@4.3.4) + transitivePeerDependencies: + - debug + dev: true + /eyes@0.1.8: resolution: {integrity: sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==} engines: {node: '> 0.1.90'} @@ -17449,6 +19624,10 @@ packages: merge2: 1.4.1 micromatch: 4.0.5 + /fast-json-patch@3.1.1: + resolution: {integrity: sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ==} + dev: true + /fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} @@ -17473,12 +19652,24 @@ packages: dependencies: reusify: 1.0.4 + /fclone@1.0.11: + resolution: {integrity: sha512-GDqVQezKzRABdeqflsgMr7ktzgF9CyS+p2oe0jJqUY6izSSbhPIQJDpoU4PtGcD7VPM9xh/dVrTu6z1nwgmEGw==} + dev: true + /fd-slicer@1.1.0: resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} dependencies: pend: 1.2.0 dev: false + /fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.3.2 + dev: false + /fflate@0.8.1: resolution: {integrity: sha512-/exOvEuc+/iaUm105QIiOt4LpBdMTWsXxqR0HDF35vx3fmaKzw7354gTilCh5rkzEt8WYyG//ku3h3nRmd7CHQ==} dev: false @@ -17553,6 +19744,18 @@ packages: pkg-dir: 4.2.0 dev: false + /find-replace@3.0.0: + resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==} + engines: {node: '>=4.0.0'} + dependencies: + array-back: 3.1.0 + + /find-up@2.1.0: + resolution: {integrity: sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==} + engines: {node: '>=4'} + dependencies: + locate-path: 2.0.0 + /find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -17567,6 +19770,14 @@ packages: locate-path: 6.0.0 path-exists: 4.0.0 + /find-up@6.3.0: + resolution: {integrity: sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + locate-path: 7.2.0 + path-exists: 5.0.0 + dev: false + /find-yarn-workspace-root2@1.2.16: resolution: {integrity: sha512-hr6hb1w8ePMpPVUK39S4RlwJzi+xPLuVuG8XlwXU3KD5Yn3qgBWVfy3AzNlDhWvE1EORCE65/Qm26rFQt3VLVA==} dependencies: @@ -17582,6 +19793,10 @@ packages: keyv: 4.5.4 rimraf: 3.0.2 + /flat@5.0.2: + resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} + hasBin: true + /flatted@3.2.9: resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} @@ -17589,11 +19804,17 @@ packages: resolution: {integrity: sha512-c5o/+Um8aqCSOXGcZoqZOm+NqtVwNsvVpWv6lfmSclU954O3wvQKxxK8zj74fPaSJbXpSLTs4PRhh+wnoCXnKg==} dev: false + /fmix@0.1.0: + resolution: {integrity: sha512-Y6hyofImk9JdzU8k5INtTXX1cu8LDlePWDFU5sftm9H+zKCr5SGrVjdhkvsim646cw5zD0nADj8oHyXMZmCZ9w==} + dependencies: + imul: 1.0.1 + dev: false + /focus-visible@5.2.0: resolution: {integrity: sha512-Rwix9pBtC1Nuy5wysTmKy+UjbDJpIfg8eHjw0rjZ1mX4GNLz1Bmd16uDpI3Gk1i70Fgcs8Csg2lPm8HULFg9DQ==} dev: false - /follow-redirects@1.15.5: + /follow-redirects@1.15.5(debug@4.3.4): resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} engines: {node: '>=4.0'} peerDependencies: @@ -17601,7 +19822,8 @@ packages: peerDependenciesMeta: debug: optional: true - dev: false + dependencies: + debug: 4.3.4(supports-color@8.1.1) /fontkit@2.0.2: resolution: {integrity: sha512-jc4k5Yr8iov8QfS6u8w2CnHWVmbOGtdBtOXMze5Y+QD966Rx6PEVWXSEGwXlsDlKtu1G12cJjcsybnqhSk/+LA==} @@ -17634,6 +19856,14 @@ packages: engines: {node: '>= 14.17'} dev: false + /form-data@2.5.1: + resolution: {integrity: sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==} + engines: {node: '>= 0.12'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + /form-data@4.0.0: resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} engines: {node: '>= 6'} @@ -17642,6 +19872,13 @@ packages: combined-stream: 1.0.8 mime-types: 2.1.35 + /formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + dependencies: + fetch-blob: 3.2.0 + dev: false + /forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -18028,6 +20265,13 @@ packages: '@fower/utils': 2.0.0 dev: false + /fp-ts@1.19.3: + resolution: {integrity: sha512-H5KQDspykdHuztLTg+ajGN0Z2qUjcEf3Ybxc6hLt0k7/zPkn29XnKnxlBPyW2XIddWrGaJBzBl4VLYOtk39yZg==} + + /fraction.js@4.3.4: + resolution: {integrity: sha512-pwiTgt0Q7t+GHZA4yaLjObx4vXmmdcS0iSJ19o8d/goUGgItX9UZWKWNnLHehxviD8wU2IWRsnR8cD5+yOJP2Q==} + dev: true + /fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} dev: true @@ -18059,6 +20303,15 @@ packages: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} dev: false + /fs-extra@0.30.0: + resolution: {integrity: sha512-UvSPKyhMn6LEd/WpUaV9C9t3zATuqoqfWc3QdPhPLb58prN9tqYPlPWi8Krxi44loBoUzlobqZ3+8tGpxxSzwA==} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 2.4.0 + klaw: 1.3.1 + path-is-absolute: 1.0.1 + rimraf: 2.7.1 + /fs-extra@10.1.0: resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==} engines: {node: '>=12'} @@ -18066,7 +20319,6 @@ packages: graceful-fs: 4.2.11 jsonfile: 6.1.0 universalify: 2.0.1 - dev: true /fs-extra@11.1.1: resolution: {integrity: sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==} @@ -18093,7 +20345,6 @@ packages: graceful-fs: 4.2.11 jsonfile: 4.0.0 universalify: 0.1.2 - dev: true /fs-extra@8.1.0: resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} @@ -18111,13 +20362,14 @@ packages: graceful-fs: 4.2.11 jsonfile: 6.1.0 universalify: 2.0.1 - dev: false /fs-jetpack@5.1.0: resolution: {integrity: sha512-Xn4fDhLydXkuzepZVsr02jakLlmoARPy+YWIclo4kh0GyNGUHnTqeH/w/qIsVn50dFxtp8otPL2t/HcPJBbxUA==} dependencies: minimatch: 5.1.6 - dev: false + + /fs-readdir-recursive@1.1.0: + resolution: {integrity: sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==} /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} @@ -18141,6 +20393,9 @@ packages: es-abstract: 1.22.3 functions-have-names: 1.2.3 + /functional-red-black-tree@1.0.1: + resolution: {integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==} + /functions-have-names@1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} @@ -18152,6 +20407,9 @@ packages: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} + /get-func-name@2.0.2: + resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} + /get-intrinsic@1.2.2: resolution: {integrity: sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==} dependencies: @@ -18173,6 +20431,10 @@ packages: resolution: {integrity: sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ==} dev: false + /get-port@3.2.0: + resolution: {integrity: sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg==} + engines: {node: '>=4'} + /get-port@7.0.0: resolution: {integrity: sha512-mDHFgApoQd+azgMdwylJrv2DX47ywGq1i5VFJE7fZ0dttNq3iQMfsU4IvEgBHojA3KqEudyu7Vq+oN8kNaNkWw==} engines: {node: '>=16'} @@ -18217,11 +20479,29 @@ packages: dependencies: basic-ftp: 5.0.4 data-uri-to-buffer: 6.0.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) fs-extra: 8.1.0 transitivePeerDependencies: - supports-color + /ghost-testrpc@0.0.2: + resolution: {integrity: sha512-i08dAEgJ2g8z5buJIrCTduwPIhih3DP+hOCTyyryikfV8T0bNvHnGXO67i0DD1H4GBDETTclPy9njZbfluQYrQ==} + hasBin: true + dependencies: + chalk: 2.4.2 + node-emoji: 1.11.0 + + /git-node-fs@1.0.0(js-git@0.7.8): + resolution: {integrity: sha512-bLQypt14llVXBg0S0u8q8HmU7g9p3ysH+NvVlae5vILuUvs759665HvmR5+wb04KjHyjFcDRxdYb4kyNnluMUQ==} + peerDependencies: + js-git: ^0.7.8 + peerDependenciesMeta: + js-git: + optional: true + dependencies: + js-git: 0.7.8 + dev: true + /git-raw-commits@2.0.11: resolution: {integrity: sha512-VnctFhw+xfj8Va1xtfEqCUD2XDrbAPSJx+hSrE5K7fGdjZruW7XV+QOrN7LF/RJyvspRiD2I0asWsxFp0ya26A==} engines: {node: '>=10'} @@ -18234,6 +20514,10 @@ packages: through2: 4.0.2 dev: true + /git-sha1@0.1.2: + resolution: {integrity: sha512-2e/nZezdVlyCopOCYHeW0onkbZg7xP1Ad6pndPy1rCygeRykefUS6r7oA5cJRGEFvseiaz5a/qUHFVX1dd6Isg==} + dev: true + /git-up@7.0.0: resolution: {integrity: sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==} dependencies: @@ -18282,6 +20566,15 @@ packages: minipass: 7.0.4 path-scurry: 1.10.1 + /glob@5.0.15: + resolution: {integrity: sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==} + dependencies: + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.2 + once: 1.4.0 + path-is-absolute: 1.0.1 + /glob@7.1.7: resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==} dependencies: @@ -18291,7 +20584,16 @@ packages: minimatch: 3.1.2 once: 1.4.0 path-is-absolute: 1.0.1 - dev: false + + /glob@7.2.0: + resolution: {integrity: sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.2 + once: 1.4.0 + path-is-absolute: 1.0.1 /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} @@ -18303,6 +20605,16 @@ packages: once: 1.4.0 path-is-absolute: 1.0.1 + /glob@9.3.5: + resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==} + engines: {node: '>=16 || 14 >=14.17'} + dependencies: + fs.realpath: 1.0.0 + minimatch: 8.0.4 + minipass: 4.2.8 + path-scurry: 1.10.1 + dev: true + /global-dirs@0.1.1: resolution: {integrity: sha512-NknMLn7F2J7aflwFOlGdNIuCDpN3VGoSoB+aap3KABFWbHVn1TCgFC+np23J8W2BiZbjfEw3BFBycSMv1AFblg==} engines: {node: '>=4'} @@ -18310,6 +20622,20 @@ packages: ini: 1.3.8 dev: true + /global-modules@2.0.0: + resolution: {integrity: sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==} + engines: {node: '>=6'} + dependencies: + global-prefix: 3.0.0 + + /global-prefix@3.0.0: + resolution: {integrity: sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==} + engines: {node: '>=6'} + dependencies: + ini: 1.3.8 + kind-of: 6.0.3 + which: 1.3.1 + /globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -18338,7 +20664,6 @@ packages: ignore: 5.3.0 merge2: 1.4.1 slash: 3.0.0 - dev: true /globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} @@ -18351,6 +20676,17 @@ packages: merge2: 1.4.1 slash: 3.0.0 + /globby@13.2.2: + resolution: {integrity: sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + dir-glob: 3.0.1 + fast-glob: 3.3.2 + ignore: 5.3.0 + merge2: 1.4.1 + slash: 4.0.0 + dev: false + /globby@6.1.0: resolution: {integrity: sha512-KVbFv2TQtbzCoxAnfD6JcHZTYCzyliEaaeM/gH8qQdkKr5s0OP9scEgvdcngyk7AVdY6YVW/TJHd+lQ/Df3Daw==} engines: {node: '>=0.10.0'} @@ -18468,16 +20804,146 @@ packages: wordwrap: 1.0.0 optionalDependencies: uglify-js: 3.17.4 - dev: true /hard-rejection@2.1.0: resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} engines: {node: '>=6'} dev: true + /hardhat-deploy-ethers@0.4.1(@nomicfoundation/hardhat-ethers@3.0.5)(hardhat-deploy@0.11.45)(hardhat@2.19.4): + resolution: {integrity: sha512-RM6JUcD0dOCjemxnKLtK7XQQI7NWn+LxF5qicGYax0PtWayEUXAewOb4WIHZ/yearhj+s2t6dL0MnHyLTENwJg==} + peerDependencies: + '@nomicfoundation/hardhat-ethers': ^3.0.2 + hardhat: ^2.16.0 + hardhat-deploy: ^0.11.34 + dependencies: + '@nomicfoundation/hardhat-ethers': 3.0.5(ethers@6.10.0)(hardhat@2.19.4) + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + hardhat-deploy: 0.11.45 + dev: false + + /hardhat-deploy@0.11.45: + resolution: {integrity: sha512-aC8UNaq3JcORnEUIwV945iJuvBwi65tjHVDU3v6mOcqik7WAzHVCJ7cwmkkipsHrWysrB5YvGF1q9S1vIph83w==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/providers': 5.7.2 + '@ethersproject/solidity': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/wallet': 5.7.0 + '@types/qs': 6.9.11 + axios: 0.21.4(debug@4.3.4) + chalk: 4.1.2 + chokidar: 3.5.3 + debug: 4.3.4(supports-color@8.1.1) + enquirer: 2.4.1 + ethers: 5.7.2 + form-data: 4.0.0 + fs-extra: 10.1.0 + match-all: 1.2.6 + murmur-128: 0.2.1 + qs: 6.11.2 + zksync-web3: 0.14.4(ethers@5.7.2) + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + + /hardhat-gas-reporter@1.0.9(hardhat@2.19.4): + resolution: {integrity: sha512-INN26G3EW43adGKBNzYWOlI3+rlLnasXTwW79YNnUhXPDa+yHESgt639dJEs37gCjhkbNKcRRJnomXEuMFBXJg==} + peerDependencies: + hardhat: ^2.0.2 + dependencies: + array-uniq: 1.0.3 + eth-gas-reporter: 0.2.27 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + sha1: 1.1.1 + transitivePeerDependencies: + - '@codechecks/client' + - bufferutil + - debug + - utf-8-validate + + /hardhat@2.19.4(ts-node@10.9.2)(typescript@5.3.3): + resolution: {integrity: sha512-fTQJpqSt3Xo9Mn/WrdblNGAfcANM6XC3tAEi6YogB4s02DmTf93A8QsGb8uR0KR8TFcpcS8lgiW4ugAIYpnbrQ==} + hasBin: true + peerDependencies: + ts-node: '*' + typescript: '*' + peerDependenciesMeta: + ts-node: + optional: true + typescript: + optional: true + dependencies: + '@ethersproject/abi': 5.7.0 + '@metamask/eth-sig-util': 4.0.1 + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-blockchain': 7.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-evm': 2.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-statemanager': 2.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + '@nomicfoundation/ethereumjs-vm': 7.0.2 + '@nomicfoundation/solidity-analyzer': 0.1.1 + '@sentry/node': 5.30.0 + '@types/bn.js': 5.1.5 + '@types/lru-cache': 5.1.1 + adm-zip: 0.4.16 + aggregate-error: 3.1.0 + ansi-escapes: 4.3.2 + chalk: 2.4.2 + chokidar: 3.5.3 + ci-info: 2.0.0 + debug: 4.3.4(supports-color@8.1.1) + enquirer: 2.4.1 + env-paths: 2.2.1 + ethereum-cryptography: 1.2.0 + ethereumjs-abi: 0.6.8 + find-up: 2.1.0 + fp-ts: 1.19.3 + fs-extra: 7.0.1 + glob: 7.2.0 + immutable: 4.3.4 + io-ts: 1.10.4 + keccak: 3.0.4 + lodash: 4.17.21 + mnemonist: 0.38.5 + mocha: 10.2.0 + p-map: 4.0.0 + raw-body: 2.5.1 + resolve: 1.17.0 + semver: 6.3.1 + solc: 0.7.3(debug@4.3.4) + source-map-support: 0.5.21 + stacktrace-parser: 0.1.10 + ts-node: 10.9.2(@types/node@20.10.6)(typescript@5.3.3) + tsort: 0.0.1 + typescript: 5.3.3 + undici: 5.28.2 + uuid: 8.3.2 + ws: 7.5.9 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + /has-bigints@1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} + /has-flag@1.0.0: + resolution: {integrity: sha512-DyYHfIYwAJmjAjSSPKANxI8bFY9YtFrgkAfinBojQ8YJTOuOuav64tMUJv584SES4xl74PmuaevIyaLESHdTAA==} + engines: {node: '>=0.10.0'} + /has-flag@2.0.0: resolution: {integrity: sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng==} engines: {node: '>=0.10.0'} @@ -18510,6 +20976,14 @@ packages: dependencies: has-symbols: 1.0.3 + /hash-base@3.1.0: + resolution: {integrity: sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==} + engines: {node: '>=4'} + dependencies: + inherits: 2.0.4 + readable-stream: 3.6.2 + safe-buffer: 5.2.1 + /hash-obj@4.0.0: resolution: {integrity: sha512-FwO1BUVWkyHasWDW4S8o0ssQXjvyghLV2rfVhnN36b2bbcj45eGiuzdn9XOvOpjV3TKQD7Gm2BWNXdE9V4KKYg==} engines: {node: '>=12'} @@ -18524,7 +20998,6 @@ packages: dependencies: inherits: 2.0.4 minimalistic-assert: 1.0.1 - dev: false /hasown@2.0.0: resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==} @@ -18660,6 +21133,10 @@ packages: space-separated-tokens: 2.0.2 dev: false + /he@1.2.0: + resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} + hasBin: true + /header-case@1.0.1: resolution: {integrity: sha512-i0q9mkOeSuhXw6bGgiQCCBgY/jlZuV/7dZXyZ9c6LcBrqwvT8eT719E9uxE5LiZftdl+z81Ugbg/VvXV4OJOeQ==} dependencies: @@ -18667,14 +21144,27 @@ packages: upper-case: 1.1.3 dev: true + /header-case@2.0.4: + resolution: {integrity: sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==} + dependencies: + capital-case: 1.0.4 + tslib: 2.6.2 + dev: false + /heap@0.2.7: resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} - dev: false /hey-listen@1.0.8: resolution: {integrity: sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==} dev: false + /hmac-drbg@1.0.1: + resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} + dependencies: + hash.js: 1.1.7 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + /hoist-non-react-statics@3.3.2: resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} dependencies: @@ -18780,6 +21270,15 @@ packages: entities: 4.5.0 dev: false + /http-basic@8.1.3: + resolution: {integrity: sha512-/EcDMwJZh3mABI2NhGfHOGOeOZITqfkEO4p/xK+l3NpyncIHUQBoMvCSF/b5GqvKtySC2srL/GGG3+EtlqlmCw==} + engines: {node: '>=6.0.0'} + dependencies: + caseless: 0.12.0 + concat-stream: 1.6.2 + http-response-object: 3.0.2 + parse-cache-control: 1.0.1 + /http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} dev: false @@ -18793,17 +21292,21 @@ packages: setprototypeof: 1.2.0 statuses: 2.0.1 toidentifier: 1.0.1 - dev: false /http-proxy-agent@7.0.0: resolution: {integrity: sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==} engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color + /http-response-object@3.0.2: + resolution: {integrity: sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==} + dependencies: + '@types/node': 10.17.60 + /http-shutdown@1.2.2: resolution: {integrity: sha512-S9wWkJ/VSY9/k4qcjG318bqJNruzE4HySUhFYknwmu6LBP97KLLfwNf+n4V1BHurvFNkSKLFnK/RsuUnRTf9Vw==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} @@ -18817,12 +21320,21 @@ packages: resolve-alpn: 1.2.1 dev: false + /https-proxy-agent@5.0.1: + resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==} + engines: {node: '>= 6'} + dependencies: + agent-base: 6.0.2 + debug: 4.3.4(supports-color@8.1.1) + transitivePeerDependencies: + - supports-color + /https-proxy-agent@7.0.2: resolution: {integrity: sha512-NmLNjm6ucYwtcUmL7JQC1ZQ57LmHP4lT15FQ8D61nak1rO6DH+fz5qNK2Ap5UN4ZapYICE3/0KodcLYSPsPbaA==} engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -18834,6 +21346,11 @@ packages: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} + /human-signals@3.0.1: + resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} + engines: {node: '>=12.20.0'} + dev: false + /human-signals@4.3.1: resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} engines: {node: '>=14.18.0'} @@ -18919,6 +21436,11 @@ packages: parent-module: 1.0.1 resolve-from: 4.0.0 + /imul@1.0.1: + resolution: {integrity: sha512-WFAgfwPLAjU66EKt6vRdTlKj4nAgIDQzh29JonLa4Bqtl6D8JrIMvWjCnx7xEjVNmP3U0fM5o8ZObk7d0f62bA==} + engines: {node: '>=0.10.0'} + dev: false + /imurmurhash@0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} @@ -19084,6 +21606,10 @@ packages: engines: {node: '>=12'} dev: false + /interpret@1.4.0: + resolution: {integrity: sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==} + engines: {node: '>= 0.10'} + /intersection-observer@0.12.2: resolution: {integrity: sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==} dev: false @@ -19094,13 +21620,18 @@ packages: loose-envify: 1.4.0 dev: false + /io-ts@1.10.4: + resolution: {integrity: sha512-b23PteSnYXSONJ6JQXRAlvJhuw8KOtkqa87W4wDtvMrud/DTJd5X+NpOOI+O/zZwVq6v0VLAaJ+1EDViKEuN9g==} + dependencies: + fp-ts: 1.19.3 + /ioredis@5.3.2: resolution: {integrity: sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==} engines: {node: '>=12.22.0'} dependencies: '@ioredis/commands': 1.2.0 cluster-key-slot: 1.1.2 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) denque: 2.1.0 lodash.defaults: 4.2.0 lodash.isarguments: 3.1.0 @@ -19186,7 +21717,6 @@ packages: /is-buffer@2.0.5: resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} engines: {node: '>=4'} - dev: false /is-callable@1.2.7: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} @@ -19248,6 +21778,10 @@ packages: dependencies: call-bind: 1.0.5 + /is-fullwidth-code-point@2.0.0: + resolution: {integrity: sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==} + engines: {node: '>=4'} + /is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} @@ -19269,6 +21803,10 @@ packages: dependencies: is-extglob: 2.1.1 + /is-hex-prefixed@1.0.0: + resolution: {integrity: sha512-WvtOiug1VFrE9v1Cydwm+FnXd3+w9GaeVUss5W4v/SLy3UW00vP+6iNF2SdnfiBoLy4bTqVdkftNGTUeOFVsbA==} + engines: {node: '>=6.5.0', npm: '>=3'} + /is-hexadecimal@2.0.1: resolution: {integrity: sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==} dev: false @@ -19293,6 +21831,11 @@ packages: resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} engines: {node: '>=8'} + /is-interactive@2.0.0: + resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==} + engines: {node: '>=12'} + dev: false + /is-json@2.0.1: resolution: {integrity: sha512-6BEnpVn1rcf3ngfmViLM6vjUjGErbdrL4rwlv+u1NO1XO8kqT4YGL8+19Q+Z/bas8tY90BTWMk2+fW1g6hQjbA==} dev: false @@ -19371,6 +21914,10 @@ packages: engines: {node: '>=0.10.0'} dev: true + /is-plain-obj@2.1.0: + resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==} + engines: {node: '>=8'} + /is-plain-obj@3.0.0: resolution: {integrity: sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==} engines: {node: '>=10'} @@ -19535,6 +22082,9 @@ packages: system-architecture: 0.1.0 dev: false + /isarray@1.0.0: + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + /isarray@2.0.5: resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} @@ -19564,7 +22114,6 @@ packages: ws: '*' dependencies: ws: 8.13.0 - dev: false /iterator.prototype@1.1.2: resolution: {integrity: sha512-DR33HMMr8EzwuRL8Y9D3u2BMj8+RqSE850jfGu59kS7tbmPLzGkZmVSfyCFSDxuZiEY6Rzt3T2NA/qU+NwVj1w==} @@ -19594,6 +22143,10 @@ packages: minimatch: 3.1.2 dev: false + /javascript-natural-sort@0.7.1: + resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==} + dev: true + /jayson@4.1.0: resolution: {integrity: sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A==} engines: {node: '>=8'} @@ -19732,6 +22285,21 @@ packages: resolution: {integrity: sha512-a+bKEcCjtuW5WTdgeXFzswSrdqi0jk4XlEtZlx5A94wCoBpFjfFTbo/Tra5SpNCl/YFZPvcV1dJc+TAYeg6ROQ==} dev: false + /js-git@0.7.8: + resolution: {integrity: sha512-+E5ZH/HeRnoc/LW0AmAyhU+mNcWBzAKE+30+IDMLSLbbK+Tdt02AdkOKq9u15rlJsDEGFqtgckc8ZM59LhhiUA==} + dependencies: + bodec: 0.1.0 + culvert: 0.1.2 + git-sha1: 0.1.2 + pako: 0.2.9 + dev: true + + /js-sdsl@4.4.2: + resolution: {integrity: sha512-dwXFwByc/ajSV6m5bcKAPwe4yDDF6D614pxmIi5odytzxRlwqF6nwoiCek80Ixc7Cvma5awClxrzFtxCQvcM8w==} + + /js-sha3@0.8.0: + resolution: {integrity: sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==} + /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -19804,7 +22372,6 @@ packages: /json-stringify-safe@5.0.1: resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==} - dev: false /json5@1.0.2: resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} @@ -19821,6 +22388,11 @@ packages: resolution: {integrity: sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==} dev: false + /jsonfile@2.4.0: + resolution: {integrity: sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==} + optionalDependencies: + graceful-fs: 4.2.11 + /jsonfile@4.0.0: resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} optionalDependencies: @@ -19842,6 +22414,9 @@ packages: engines: {node: '>=0.10.0'} dev: false + /jsonschema@1.4.1: + resolution: {integrity: sha512-S6cATIPVv1z0IlxdN+zUk5EPjkGCdnhN4wVSBlvoUO1tOLJootbo9CquNJmbIh4yikWHiUedhRYrNPn1arpEmQ==} + /jsonwebtoken@9.0.2: resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} engines: {node: '>=12', npm: '>=6'} @@ -19897,7 +22472,6 @@ packages: node-addon-api: 2.0.2 node-gyp-build: 4.8.0 readable-stream: 3.6.2 - dev: false /keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} @@ -19920,6 +22494,11 @@ packages: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} + /klaw@1.3.1: + resolution: {integrity: sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==} + optionalDependencies: + graceful-fs: 4.2.11 + /kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} @@ -19946,6 +22525,11 @@ packages: resolution: {integrity: sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==} dev: false + /lazy@1.0.11: + resolution: {integrity: sha512-Y+CjUfLmIpoUCCRl0ub4smrYtGGr5AOa2AKOaWelGHOGz33X/Y/KizefGqbkwfz44+cnq/+9habclf8vOmu2LA==} + engines: {node: '>=0.2.0'} + dev: true + /less@4.2.0: resolution: {integrity: sha512-P3b3HJDBtSzsXUl0im2L7gTO5Ubg8mEN6G8qoTS77iXxXX4Hvu4Qj540PZDvQ8V6DmX6iXo98k7Md0Cm1PrLaA==} engines: {node: '>=6'} @@ -19964,11 +22548,36 @@ packages: source-map: 0.6.1 dev: false + /level-supports@4.0.1: + resolution: {integrity: sha512-PbXpve8rKeNcZ9C1mUicC9auIYFyGpkV9/i6g76tLgANwWhtG2v7I4xNBUlkn3lE2/dZF3Pi0ygYGtLc4RXXdA==} + engines: {node: '>=12'} + + /level-transcoder@1.0.1: + resolution: {integrity: sha512-t7bFwFtsQeD8cl8NIoQ2iwxA0CL/9IFw7/9gAjOonH0PWTTiRfY7Hq+Ejbsxh86tXobDQ6IOiddjNYIfOBs06w==} + engines: {node: '>=12'} + dependencies: + buffer: 6.0.3 + module-error: 1.0.2 + + /level@8.0.0: + resolution: {integrity: sha512-ypf0jjAk2BWI33yzEaaotpq7fkOPALKAgDBxggO6Q9HGX2MRXn0wbP1Jn/tJv1gtL867+YOjOB49WaUF3UoJNQ==} + engines: {node: '>=12'} + dependencies: + browser-level: 1.0.1 + classic-level: 1.4.1 + /leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} engines: {node: '>=6'} dev: false + /levn@0.3.0: + resolution: {integrity: sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==} + engines: {node: '>= 0.8.0'} + dependencies: + prelude-ls: 1.1.2 + type-check: 0.3.2 + /levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -20212,7 +22821,7 @@ packages: dependencies: chalk: 5.3.0 commander: 11.0.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) execa: 7.2.0 lilconfig: 2.1.0 listr2: 6.6.1 @@ -20364,6 +22973,13 @@ packages: resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} dev: false + /locate-path@2.0.0: + resolution: {integrity: sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==} + engines: {node: '>=4'} + dependencies: + p-locate: 2.0.0 + path-exists: 3.0.0 + /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -20376,13 +22992,22 @@ packages: dependencies: p-locate: 5.0.0 + /locate-path@7.2.0: + resolution: {integrity: sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + p-locate: 6.0.0 + dev: false + /lodash-es@4.17.21: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} dev: false /lodash.camelcase@4.3.0: resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} - dev: true + + /lodash.clonedeep@4.5.0: + resolution: {integrity: sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==} /lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} @@ -20408,7 +23033,6 @@ packages: /lodash.isequal@4.5.0: resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==} - dev: false /lodash.isfunction@3.0.9: resolution: {integrity: sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==} @@ -20455,6 +23079,9 @@ packages: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} dev: true + /lodash.truncate@4.4.2: + resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} + /lodash.uniq@4.5.0: resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} dev: true @@ -20466,6 +23093,11 @@ packages: /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + /log-driver@1.2.7: + resolution: {integrity: sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==} + engines: {node: '>=0.8.6'} + dev: true + /log-symbols@3.0.0: resolution: {integrity: sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==} engines: {node: '>=8'} @@ -20480,6 +23112,14 @@ packages: chalk: 4.1.2 is-unicode-supported: 0.1.0 + /log-symbols@5.1.0: + resolution: {integrity: sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==} + engines: {node: '>=12'} + dependencies: + chalk: 5.3.0 + is-unicode-supported: 1.3.0 + dev: false + /log-update@5.0.1: resolution: {integrity: sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -20501,6 +23141,11 @@ packages: dependencies: js-tokens: 4.0.0 + /loupe@2.3.7: + resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==} + dependencies: + get-func-name: 2.0.2 + /lower-case-first@1.0.2: resolution: {integrity: sha512-UuxaYakO7XeONbKrZf5FEgkantPf5DUqDayzP5VXZrtRPdH86s4kN47I8B3TW10S4QKiE3ziHNf3kRN//okHjA==} dependencies: @@ -20515,7 +23160,6 @@ packages: resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==} dependencies: tslib: 2.6.2 - dev: true /lowercase-keys@3.0.0: resolution: {integrity: sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==} @@ -20547,6 +23191,9 @@ packages: resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} engines: {node: '>=12'} + /lru_map@0.3.3: + resolution: {integrity: sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==} + /lucide-react@0.289.0(react@18.2.0): resolution: {integrity: sha512-D3/kt5h4KVmO9Bqlhky/szWI3puEU/KJfQWCeX8Zhvx3xx0SQ4t6vbwiK9ORBbiaqXefkBbXjoq7fOBd7s5yXQ==} peerDependencies: @@ -20627,6 +23274,9 @@ packages: uc.micro: 1.0.6 dev: false + /markdown-table@1.1.3: + resolution: {integrity: sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q==} + /markdown-table@3.0.3: resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==} dev: false @@ -20643,6 +23293,10 @@ packages: hasBin: true dev: false + /match-all@1.2.6: + resolution: {integrity: sha512-0EESkXiTkWzrQQntBu2uzKvLu6vVkUGz40nGPbSZuegcfE5UuSzNjLaIu76zJWuaT/2I3Z/8M06OlUOZLGwLlQ==} + dev: false + /match-sorter@6.3.3: resolution: {integrity: sha512-sgiXxrRijEe0SzHKGX4HouCpfHRPnqteH42UdMEW7BlWy990ZkzcvonJGv4Uu9WE7Y1f8Yocm91+4qFPCbmNww==} dependencies: @@ -20650,6 +23304,33 @@ packages: remove-accents: 0.5.0 dev: false + /mathjs@11.12.0: + resolution: {integrity: sha512-UGhVw8rS1AyedyI55DGz9q1qZ0p98kyKPyc9vherBkoueLntPfKtPBh14x+V4cdUWK0NZV2TBwqRFlvadscSuw==} + engines: {node: '>= 14'} + hasBin: true + dependencies: + '@babel/runtime': 7.23.8 + complex.js: 2.1.1 + decimal.js: 10.4.3 + escape-latex: 1.2.0 + fraction.js: 4.3.4 + javascript-natural-sort: 0.7.1 + seedrandom: 3.0.5 + tiny-emitter: 2.1.0 + typed-function: 4.1.1 + dev: true + + /mcl-wasm@0.7.9: + resolution: {integrity: sha512-iJIUcQWA88IJB/5L15GnJVnSQJmf/YaxxV6zRavv83HILHaJQb6y0iFyDMdDO0gN8X37tdxmAOrH/P8B6RB8sQ==} + engines: {node: '>=8.9.0'} + + /md5.js@1.3.5: + resolution: {integrity: sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==} + dependencies: + hash-base: 3.1.0 + inherits: 2.0.4 + safe-buffer: 5.2.1 + /mdast-util-definitions@5.1.2: resolution: {integrity: sha512-8SVPMuHqlPME/z3gqVwWY4zVXn8lqKv/pAhC57FuJ40ImXyBpmO5ukh98zB2v7Blql2FiHjHv9LVztSIqjY+MA==} dependencies: @@ -20907,6 +23588,18 @@ packages: engines: {node: '>= 0.6'} dev: false + /memory-level@1.0.0: + resolution: {integrity: sha512-UXzwewuWeHBz5krr7EvehKcmLFNoXxGcvuYhC41tRnkrTbJohtS7kVn9akmgirtRygg+f7Yjsfi8Uu5SGSQ4Og==} + engines: {node: '>=12'} + dependencies: + abstract-level: 1.0.4 + functional-red-black-tree: 1.0.1 + module-error: 1.0.2 + + /memorystream@0.3.1: + resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} + engines: {node: '>= 0.10.0'} + /meow@6.1.1: resolution: {integrity: sha512-3YffViIt2QWgTy6Pale5QpopX/IvU3LPL03jOTqp6pGj3VjesdO/U8CuHMKpnQr4shCNCM5fd5XFFvIIl6JBHg==} engines: {node: '>=8'} @@ -20984,6 +23677,9 @@ packages: engines: {node: '>= 0.6'} dev: false + /micro-ftch@0.3.1: + resolution: {integrity: sha512-/0LLxhzP0tfiR5hcQebtudP56gUurs2CLkGarnCiB/OqEyUFQ6U3paQi/tgLv0hBJYt2rnr9MNpxz4fiiugstg==} + /micromark-core-commonmark@1.1.0: resolution: {integrity: sha512-BgHO1aRbolh2hcrzL2d1La37V0Aoz73ymF8rAcKnohLy93titmv62E0gP8Hrx9PKcKrqCZ1BbLGbP3bEhoXYlw==} dependencies: @@ -21461,7 +24157,7 @@ packages: resolution: {integrity: sha512-uD66tJj54JLYq0De10AhWycZWGQNUvDI55xPgk2sQM5kn1JYlhbCMTtEeT27+vAhW2FBQxLlOmS3pmA7/2z4aA==} dependencies: '@types/debug': 4.1.12 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) decode-named-character-reference: 1.0.2 micromark-core-commonmark: 1.1.0 micromark-factory-space: 1.1.0 @@ -21485,7 +24181,7 @@ packages: resolution: {integrity: sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==} dependencies: '@types/debug': 4.1.12 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) decode-named-character-reference: 1.0.2 devlop: 1.1.0 micromark-core-commonmark: 2.0.0 @@ -21581,19 +24277,33 @@ packages: /minimalistic-assert@1.0.1: resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} - dev: false + + /minimalistic-crypto-utils@1.0.1: + resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: brace-expansion: 1.1.11 + /minimatch@5.0.1: + resolution: {integrity: sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + /minimatch@5.1.6: resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} engines: {node: '>=10'} dependencies: brace-expansion: 2.0.1 - dev: false + + /minimatch@8.0.4: + resolution: {integrity: sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==} + engines: {node: '>=16 || 14 >=14.17'} + dependencies: + brace-expansion: 2.0.1 + dev: true /minimatch@9.0.2: resolution: {integrity: sha512-PZOT9g5v2ojiTL7r1xF6plNHLtOeTpSlDI007As2NlA2aYBMfVom17yqa6QzhmDP8QOhn7LjHTg7DFCVSSa6yg==} @@ -21620,6 +24330,11 @@ packages: /minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + /minipass@4.2.8: + resolution: {integrity: sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==} + engines: {node: '>=8'} + dev: true + /minipass@7.0.4: resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} engines: {node: '>=16 || 14 >=14.17'} @@ -21642,7 +24357,11 @@ packages: hasBin: true dependencies: minimist: 1.2.8 - dev: true + + /mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true /mlly@1.5.0: resolution: {integrity: sha512-NPVQvAY1xr1QoVeG0cy8yUYC7FQcOx6evl/RjT1wL5FvzPnzOysoqB/jmx/DhssT2dYa8nxECLAaFI/+gVLhDQ==} @@ -21657,6 +24376,46 @@ packages: resolution: {integrity: sha512-kysx9gAGbvrzuFYxKkcRjnsg/NK61ovJOV4F1cHTRl9T5leg+bo6WI0pWIvOFh1Z/yDL0cjA5R3EEGPPLDv/XA==} dev: false + /mnemonist@0.38.5: + resolution: {integrity: sha512-bZTFT5rrPKtPJxj8KSV0WkPyNxl72vQepqqVUAW2ARUpUSF2qXMB6jZj7hW5/k7C1rtpzqbD/IIbJwLXUjCHeg==} + dependencies: + obliterator: 2.0.4 + + /mocha@10.2.0: + resolution: {integrity: sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==} + engines: {node: '>= 14.0.0'} + hasBin: true + dependencies: + ansi-colors: 4.1.1 + browser-stdout: 1.3.1 + chokidar: 3.5.3 + debug: 4.3.4(supports-color@8.1.1) + diff: 5.0.0 + escape-string-regexp: 4.0.0 + find-up: 5.0.0 + glob: 7.2.0 + he: 1.2.0 + js-yaml: 4.1.0 + log-symbols: 4.1.0 + minimatch: 5.0.1 + ms: 2.1.3 + nanoid: 3.3.3 + serialize-javascript: 6.0.0 + strip-json-comments: 3.1.1 + supports-color: 8.1.1 + workerpool: 6.2.1 + yargs: 16.2.0 + yargs-parser: 20.2.4 + yargs-unparser: 2.0.0 + + /module-details-from-path@1.0.3: + resolution: {integrity: sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==} + dev: true + + /module-error@1.0.2: + resolution: {integrity: sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA==} + engines: {node: '>=10'} + /motion@10.16.2: resolution: {integrity: sha512-p+PurYqfUdcJZvtnmAqu5fJgV2kR0uLFQuBKtLeFVTrYEVllI99tiOTSefVNYuip9ELTEkepIIDftNdze76NAQ==} dependencies: @@ -21715,6 +24474,14 @@ packages: resolution: {integrity: sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==} dev: false + /murmur-128@0.2.1: + resolution: {integrity: sha512-WseEgiRkI6aMFBbj8Cg9yBj/y+OdipwVC7zUo3W2W1JAJITwouUOtpqsmGSg67EQmwwSyod7hsVsWY5LsrfQVg==} + dependencies: + encode-utf8: 1.0.3 + fmix: 0.1.0 + imul: 1.0.1 + dev: false + /mute-stream@0.0.8: resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} @@ -21730,6 +24497,11 @@ packages: object-assign: 4.1.1 thenify-all: 1.6.0 + /nanoid@3.3.3: + resolution: {integrity: sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + /nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -21745,6 +24517,9 @@ packages: resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} dev: false + /napi-macros@2.2.2: + resolution: {integrity: sha512-hmEVtAGYzVQpCKdbQea4skABsdXW4RUh5t5mJ2zzqowJS2OyXZTU1KhDVFhx+NlWZ4ap9mqR9TcDO3LTTttd+g==} + /napi-wasm@1.1.0: resolution: {integrity: sha512-lHwIAJbmLSjF9VDRm9GoVOy9AGp3aIvkjv+Kvz9h16QR3uSVYH78PNQUnT2U4X53mhlnV2M7wrhibQ3GHicDmg==} dev: false @@ -21756,6 +24531,18 @@ packages: /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + /needle@2.4.0: + resolution: {integrity: sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==} + engines: {node: '>= 4.4.x'} + hasBin: true + dependencies: + debug: 3.2.7 + iconv-lite: 0.4.24 + sax: 1.3.0 + transitivePeerDependencies: + - supports-color + dev: true + /needle@3.3.1: resolution: {integrity: sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==} engines: {node: '>= 4.4.x'} @@ -22012,7 +24799,6 @@ packages: dependencies: lower-case: 2.0.2 tslib: 2.6.2 - dev: true /node-abi@3.54.0: resolution: {integrity: sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA==} @@ -22023,7 +24809,6 @@ packages: /node-addon-api@2.0.2: resolution: {integrity: sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==} - dev: false /node-addon-api@4.3.0: resolution: {integrity: sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==} @@ -22038,6 +24823,16 @@ packages: engines: {node: ^16 || ^18 || >= 20} dev: false + /node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + dev: false + + /node-emoji@1.11.0: + resolution: {integrity: sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==} + dependencies: + lodash: 4.17.21 + /node-fetch-native@1.6.1: resolution: {integrity: sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==} dev: false @@ -22054,6 +24849,15 @@ packages: whatwg-url: 5.0.0 dev: false + /node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + dev: false + /node-forge@1.3.1: resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} engines: {node: '>= 6.13.0'} @@ -22079,7 +24883,6 @@ packages: /node-gyp-build@4.8.0: resolution: {integrity: sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==} hasBin: true - dev: false /node-object-hash@3.0.0: resolution: {integrity: sha512-jLF6tlyletktvSAawuPmH1SReP0YfZQ+tBrDiTCK+Ai7eXPMS9odi5xW/iKC7ZhrWJJ0Z5xYcW/x+1fVMn1Qvw==} @@ -22113,10 +24916,20 @@ packages: big-integer: 1.6.52 dev: false + /nofilter@3.1.0: + resolution: {integrity: sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g==} + engines: {node: '>=12.19'} + /non-layered-tidy-tree-layout@2.0.2: resolution: {integrity: sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==} dev: false + /nopt@3.0.6: + resolution: {integrity: sha512-4GUt3kSEYmk4ITxzB/b9vaIDfUVWN/Ml1Fwl11IlnIG2iaJ9O6WXZ9SrYM9NLI8OCBieN2Y8SWC2oJV0RQ7qYg==} + hasBin: true + dependencies: + abbrev: 1.0.9 + /normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} dependencies: @@ -22190,6 +25003,14 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: false + /nssocket@0.6.0: + resolution: {integrity: sha512-a9GSOIql5IqgWJR3F/JXG4KpJTA3Z53Cj0MeMvGpglytB1nxE4PdFNC0jINe27CS7cGivoynwc054EzCcT3M3w==} + engines: {node: '>= 0.10.x'} + dependencies: + eventemitter2: 0.4.14 + lazy: 1.0.11 + dev: true + /nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} dependencies: @@ -22199,6 +25020,13 @@ packages: resolution: {integrity: sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw==} dev: false + /number-to-bn@1.7.0: + resolution: {integrity: sha512-wsJ9gfSz1/s4ZsJN01lyonwuxA1tml6X1yBDnfpMglypcBRFZZkus26EdPSlqS5GJfYddVZa22p3VNb3z5m5Ig==} + engines: {node: '>=6.5.0', npm: '>=3'} + dependencies: + bn.js: 4.11.6 + strip-hex-prefix: 1.0.0 + /oauth@0.9.15: resolution: {integrity: sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA==} dev: false @@ -22273,6 +25101,9 @@ packages: define-properties: 1.2.1 es-abstract: 1.22.3 + /obliterator@2.0.4: + resolution: {integrity: sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ==} + /octokit@3.1.2: resolution: {integrity: sha512-MG5qmrTL5y8KYwFgE1A4JWmgfQBaIETE/lOlfwNYx1QOtCQHGVxkRJmdUJltFc1HVn73d61TlMhMyNTOtMl+ng==} engines: {node: '>= 18'} @@ -22339,6 +25170,17 @@ packages: oidc-token-hash: 5.0.3 dev: false + /optionator@0.8.3: + resolution: {integrity: sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==} + engines: {node: '>= 0.8.0'} + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.3.0 + prelude-ls: 1.1.2 + type-check: 0.3.2 + word-wrap: 1.2.5 + /optionator@0.9.3: resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==} engines: {node: '>= 0.8.0'} @@ -22378,10 +25220,28 @@ packages: strip-ansi: 6.0.1 wcwidth: 1.0.1 + /ora@6.3.1: + resolution: {integrity: sha512-ERAyNnZOfqM+Ao3RAvIXkYh5joP220yf59gVe2X/cI6SiCxIdi4c9HZKZD8R6q/RDXEje1THBju6iExiSsgJaQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + chalk: 5.3.0 + cli-cursor: 4.0.0 + cli-spinners: 2.9.2 + is-interactive: 2.0.0 + is-unicode-supported: 1.3.0 + log-symbols: 5.1.0 + stdin-discarder: 0.1.0 + strip-ansi: 7.1.0 + wcwidth: 1.0.1 + dev: false + /ordered-binary@1.5.1: resolution: {integrity: sha512-5VyHfHY3cd0iza71JepYG50My+YUbrFtGoUz2ooEydPyPM7Aai/JW098juLr+RG6+rDJuzNNTsEQu2DZa1A41A==} dev: false + /ordinal@1.0.3: + resolution: {integrity: sha512-cMddMgb2QElm8G7vdaa02jhUNbTSrhsgAGUz1OokD83uJTwSUn+nKoNoKVVaRa08yF6sgfO7Maou1+bgLd9rdQ==} + /os-tmpdir@1.0.2: resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} @@ -22407,6 +25267,12 @@ packages: engines: {node: '>=4'} dev: false + /p-limit@1.3.0: + resolution: {integrity: sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==} + engines: {node: '>=4'} + dependencies: + p-try: 1.0.0 + /p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -22419,6 +25285,19 @@ packages: dependencies: yocto-queue: 0.1.0 + /p-limit@4.0.0: + resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + yocto-queue: 1.0.0 + dev: false + + /p-locate@2.0.0: + resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==} + engines: {node: '>=4'} + dependencies: + p-limit: 1.3.0 + /p-locate@4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} engines: {node: '>=8'} @@ -22431,6 +25310,13 @@ packages: dependencies: p-limit: 3.1.0 + /p-locate@6.0.0: + resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + p-limit: 4.0.0 + dev: false + /p-map@2.1.0: resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} engines: {node: '>=6'} @@ -22442,6 +25328,16 @@ packages: aggregate-error: 3.1.0 dev: true + /p-map@4.0.0: + resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} + engines: {node: '>=10'} + dependencies: + aggregate-error: 3.1.0 + + /p-try@1.0.0: + resolution: {integrity: sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==} + engines: {node: '>=4'} + /p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} @@ -22452,7 +25348,7 @@ packages: dependencies: '@tootallnate/quickjs-emscripten': 0.23.0 agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) get-uri: 6.0.2 http-proxy-agent: 7.0.0 https-proxy-agent: 7.0.2 @@ -22481,7 +25377,6 @@ packages: /pako@0.2.9: resolution: {integrity: sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==} - dev: false /pako@1.0.11: resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} @@ -22493,12 +25388,22 @@ packages: no-case: 2.3.2 dev: true + /param-case@3.0.4: + resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==} + dependencies: + dot-case: 3.0.4 + tslib: 2.6.2 + dev: false + /parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} dependencies: callsites: 3.1.0 + /parse-cache-control@1.0.1: + resolution: {integrity: sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==} + /parse-entities@4.0.1: resolution: {integrity: sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==} dependencies: @@ -22575,6 +25480,13 @@ packages: upper-case-first: 1.1.2 dev: true + /pascal-case@3.1.2: + resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} + dependencies: + no-case: 3.0.4 + tslib: 2.6.2 + dev: false + /patch-console@1.0.0: resolution: {integrity: sha512-nxl9nrnLQmh64iTzMfyylSlRozL7kAXIaxw1fVcLYdyhNkJCRUzirRZTikXGJsg+hc4fqpneTK6iU2H1Q8THSA==} engines: {node: '>=10'} @@ -22586,10 +25498,26 @@ packages: no-case: 2.3.2 dev: true + /path-case@3.0.4: + resolution: {integrity: sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==} + dependencies: + dot-case: 3.0.4 + tslib: 2.6.2 + dev: false + + /path-exists@3.0.0: + resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} + engines: {node: '>=4'} + /path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} + /path-exists@5.0.0: + resolution: {integrity: sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: false + /path-is-absolute@1.0.1: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} @@ -22633,6 +25561,19 @@ packages: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} dev: false + /pathval@1.1.1: + resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + + /pbkdf2@3.1.2: + resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==} + engines: {node: '>=0.12'} + dependencies: + create-hash: 1.2.0 + create-hmac: 1.1.7 + ripemd160: 2.0.2 + safe-buffer: 5.2.1 + sha.js: 2.4.11 + /pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} dev: false @@ -22658,6 +25599,22 @@ packages: hasBin: true dev: true + /pidusage@2.0.21: + resolution: {integrity: sha512-cv3xAQos+pugVX+BfXpHsbyz/dLzX+lr44zNMsYiGxUw+kV5sgQCIcLd1z+0vq+KyC7dJ+/ts2PsfgWfSC3WXA==} + engines: {node: '>=8'} + requiresBuild: true + dependencies: + safe-buffer: 5.2.1 + dev: true + optional: true + + /pidusage@3.0.2: + resolution: {integrity: sha512-g0VU+y08pKw5M8EZ2rIGiEBaB8wrQMjYGFfW2QVIfyT8V+fq8YFLkvlz4bz5ljvFDJYNFCWT3PWqcRr2FKO81w==} + engines: {node: '>=10'} + dependencies: + safe-buffer: 5.2.1 + dev: true + /pify@2.3.0: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} @@ -22834,6 +25791,97 @@ packages: - whiskers dev: false + /pm2-axon-rpc@0.7.1: + resolution: {integrity: sha512-FbLvW60w+vEyvMjP/xom2UPhUN/2bVpdtLfKJeYM3gwzYhoTEEChCOICfFzxkxuoEleOlnpjie+n1nue91bDQw==} + engines: {node: '>=5'} + dependencies: + debug: 4.3.4(supports-color@8.1.1) + transitivePeerDependencies: + - supports-color + dev: true + + /pm2-axon@4.0.1: + resolution: {integrity: sha512-kES/PeSLS8orT8dR5jMlNl+Yu4Ty3nbvZRmaAtROuVm9nYYGiaoXqqKQqQYzWQzMYWUKHMQTvBlirjE5GIIxqg==} + engines: {node: '>=5'} + dependencies: + amp: 0.3.1 + amp-message: 0.1.2 + debug: 4.3.4(supports-color@8.1.1) + escape-string-regexp: 4.0.0 + transitivePeerDependencies: + - supports-color + dev: true + + /pm2-deploy@1.0.2: + resolution: {integrity: sha512-YJx6RXKrVrWaphEYf++EdOOx9EH18vM8RSZN/P1Y+NokTKqYAca/ejXwVLyiEpNju4HPZEk3Y2uZouwMqUlcgg==} + engines: {node: '>=4.0.0'} + dependencies: + run-series: 1.1.9 + tv4: 1.3.0 + dev: true + + /pm2-multimeter@0.1.2: + resolution: {integrity: sha512-S+wT6XfyKfd7SJIBqRgOctGxaBzUOmVQzTAS+cg04TsEUObJVreha7lvCfX8zzGVr871XwCSnHUU7DQQ5xEsfA==} + dependencies: + charm: 0.1.2 + dev: true + + /pm2-sysmonit@1.2.8: + resolution: {integrity: sha512-ACOhlONEXdCTVwKieBIQLSi2tQZ8eKinhcr9JpZSUAL8Qy0ajIgRtsLxG/lwPOW3JEKqPyw/UaHmTWhUzpP4kA==} + requiresBuild: true + dependencies: + async: 3.2.5 + debug: 4.3.4(supports-color@8.1.1) + pidusage: 2.0.21 + systeminformation: 5.21.24 + tx2: 1.0.5 + transitivePeerDependencies: + - supports-color + dev: true + optional: true + + /pm2@5.3.1: + resolution: {integrity: sha512-DLVQHpSR1EegaTaRH3KbRXxpPVaqYwAp3uHSCtCsS++LSErvk07WSxuUnntFblBRqNU/w2KQyqs12mSq5wurkg==} + engines: {node: '>=10.0.0'} + hasBin: true + dependencies: + '@pm2/agent': 2.0.3 + '@pm2/io': 5.0.2 + '@pm2/js-api': 0.8.0 + '@pm2/pm2-version-check': 1.0.4 + async: 3.2.5 + blessed: 0.1.81 + chalk: 3.0.0 + chokidar: 3.5.3 + cli-tableau: 2.0.1 + commander: 2.15.1 + croner: 4.1.97 + dayjs: 1.11.10 + debug: 4.3.4(supports-color@8.1.1) + enquirer: 2.3.6 + eventemitter2: 5.0.1 + fclone: 1.0.11 + mkdirp: 1.0.4 + needle: 2.4.0 + pidusage: 3.0.2 + pm2-axon: 4.0.1 + pm2-axon-rpc: 0.7.1 + pm2-deploy: 1.0.2 + pm2-multimeter: 0.1.2 + promptly: 2.2.0 + semver: 7.5.4 + source-map-support: 0.5.21 + sprintf-js: 1.1.2 + vizion: 2.2.1 + yamljs: 0.3.0 + optionalDependencies: + pm2-sysmonit: 1.2.8 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: true + /pngjs@5.0.0: resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==} engines: {node: '>=10.13.0'} @@ -22946,15 +25994,30 @@ packages: which-pm: 2.0.0 dev: true + /prelude-ls@1.1.2: + resolution: {integrity: sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==} + engines: {node: '>= 0.8.0'} + /prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + /prettier-plugin-solidity@1.3.1(prettier@3.1.0): + resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==} + engines: {node: '>=16'} + peerDependencies: + prettier: '>=2.3.0' + dependencies: + '@solidity-parser/parser': 0.17.0 + prettier: 3.1.0 + semver: 7.5.4 + solidity-comments-extractor: 0.0.8 + dev: true + /prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} hasBin: true - dev: true /prettier@3.0.3: resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==} @@ -22990,6 +26053,9 @@ packages: engines: {node: '>=6'} dev: false + /process-nextick-args@2.0.1: + resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + /process-warning@1.0.0: resolution: {integrity: sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==} dev: false @@ -23004,6 +26070,17 @@ packages: engines: {node: '>=0.4.0'} dev: false + /promise@8.3.0: + resolution: {integrity: sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg==} + dependencies: + asap: 2.0.6 + + /promptly@2.2.0: + resolution: {integrity: sha512-aC9j+BZsRSSzEsXBNBwDnAxujdx19HycZoKgRgzWnS8eOHg1asuf9heuLprfbe739zY3IdUQx+Egv6Jn135WHA==} + dependencies: + read: 1.0.7 + dev: true + /prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} dependencies: @@ -23036,7 +26113,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) http-proxy-agent: 7.0.0 https-proxy-agent: 7.0.2 lru-cache: 7.18.3 @@ -23084,7 +26161,7 @@ packages: '@puppeteer/browsers': 1.9.1 chromium-bidi: 0.5.4(devtools-protocol@0.0.1232444) cross-fetch: 4.0.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) devtools-protocol: 0.0.1232444 ws: 8.16.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: @@ -23121,7 +26198,6 @@ packages: engines: {node: '>=0.6'} dependencies: side-channel: 1.0.4 - dev: false /query-string@6.14.1: resolution: {integrity: sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==} @@ -23187,7 +26263,6 @@ packages: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} dependencies: safe-buffer: 5.2.1 - dev: false /range-parser@1.2.1: resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} @@ -23202,7 +26277,6 @@ packages: http-errors: 2.0.0 iconv-lite: 0.4.24 unpipe: 1.0.0 - dev: false /rc-resize-observer@1.4.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-PnMVyRid9JLxFavTjeDXEXo65HCRqbmLBw9xX9gfC4BZiSzbLXKzW3jPz+J0P71pLbD5tBMTT+mkstV5gD0c9Q==} @@ -23649,6 +26723,24 @@ packages: strip-bom: 3.0.0 dev: true + /read@1.0.7: + resolution: {integrity: sha512-rSOKNYUmaxy0om1BNjMN4ezNT6VKK+2xF4GBhc81mkH7L60i6dp8qPYrkndNLT3QPphoII3maL9PVC9XmhHwVQ==} + engines: {node: '>=0.8'} + dependencies: + mute-stream: 0.0.8 + dev: true + + /readable-stream@2.3.8: + resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} + dependencies: + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 1.0.0 + process-nextick-args: 2.0.1 + safe-buffer: 5.1.2 + string_decoder: 1.1.1 + util-deprecate: 1.0.2 + /readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -23672,6 +26764,18 @@ packages: engines: {node: '>= 12.13.0'} dev: false + /rechoir@0.6.2: + resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==} + engines: {node: '>= 0.10'} + dependencies: + resolve: 1.22.8 + + /recursive-readdir@2.2.3: + resolution: {integrity: sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA==} + engines: {node: '>=6.0.0'} + dependencies: + minimatch: 3.1.2 + /redent@3.0.0: resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} engines: {node: '>=8'} @@ -23692,6 +26796,10 @@ packages: redis-errors: 1.2.0 dev: false + /reduce-flatten@2.0.0: + resolution: {integrity: sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==} + engines: {node: '>=6'} + /reflect-metadata@0.1.13: resolution: {integrity: sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==} dev: false @@ -23892,6 +27000,18 @@ packages: resolution: {integrity: sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A==} dev: false + /req-cwd@2.0.0: + resolution: {integrity: sha512-ueoIoLo1OfB6b05COxAA9UpeoscNpYyM+BqYlA7H6LVF4hKGPXQQSSaD2YmvDVJMkk4UDpAHIeU1zG53IqjvlQ==} + engines: {node: '>=4'} + dependencies: + req-from: 2.0.0 + + /req-from@2.0.0: + resolution: {integrity: sha512-LzTfEVDVQHBRfjOUMgNBA+V6DWsSnoeKzf42J7l0xa/B4jyPOuuF5MlNSmomLNGemWTnV2TIdjSSLnEn95fOQA==} + engines: {node: '>=4'} + dependencies: + resolve-from: 3.0.0 + /require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -23900,6 +27020,17 @@ packages: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} + /require-in-the-middle@5.2.0: + resolution: {integrity: sha512-efCx3b+0Z69/LGJmm9Yvi4cqEdxnoGnxYxGxBghkkTTFeXRtTCmmhO0AnAfHz59k957uTSuy8WaHqOs8wbYUWg==} + engines: {node: '>=6'} + dependencies: + debug: 4.3.4(supports-color@8.1.1) + module-details-from-path: 1.0.3 + resolve: 1.22.8 + transitivePeerDependencies: + - supports-color + dev: true + /require-main-filename@2.0.0: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} @@ -23911,6 +27042,10 @@ packages: resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==} dev: false + /resolve-from@3.0.0: + resolution: {integrity: sha512-GnlH6vxLymXJNMBo7XP1fJIzBFbdYt49CuTwmB/6N53t+kMPRMFKz783LlQ4tv28XoQfMWinAJX6WCGf2IlaIw==} + engines: {node: '>=4'} + /resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} @@ -23929,6 +27064,14 @@ packages: /resolve-pkg-maps@1.0.0: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + /resolve@1.1.7: + resolution: {integrity: sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg==} + + /resolve@1.17.0: + resolution: {integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==} + dependencies: + path-parse: 1.0.7 + /resolve@1.22.8: resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} hasBin: true @@ -23965,7 +27108,6 @@ packages: dependencies: onetime: 5.1.2 signal-exit: 3.0.7 - dev: true /restructure@3.0.0: resolution: {integrity: sha512-Xj8/MEIhhfj9X2rmD9iJ4Gga9EFqVlpMj3vfLnV2r/Mh5jRMryNV+6lWh9GdJtDBcBSPIqzRdfBQ3wDtNFv/uw==} @@ -23984,7 +27126,6 @@ packages: hasBin: true dependencies: glob: 7.2.3 - dev: false /rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} @@ -23992,6 +27133,26 @@ packages: dependencies: glob: 7.2.3 + /rimraf@4.4.1: + resolution: {integrity: sha512-Gk8NlF062+T9CqNGn6h4tls3k6T1+/nXdOcSZVikNVtlRdYpA7wRJJMoXmuvOnLW844rPjdQ7JgXCYM6PPC/og==} + engines: {node: '>=14'} + hasBin: true + dependencies: + glob: 9.3.5 + dev: true + + /ripemd160@2.0.2: + resolution: {integrity: sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==} + dependencies: + hash-base: 3.1.0 + inherits: 2.0.4 + + /rlp@2.2.7: + resolution: {integrity: sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==} + hasBin: true + dependencies: + bn.js: 5.2.1 + /robust-predicates@3.0.2: resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==} dev: false @@ -24045,11 +27206,23 @@ packages: engines: {node: '>=0.12.0'} dev: false + /run-parallel-limit@1.1.0: + resolution: {integrity: sha512-jJA7irRNM91jaKc3Hcl1npHsFLOXOoTkPCUL1JEa1R82O2miplXXRaGdjW/KM/98YQWDhJLiSs793CnXfblJUw==} + dependencies: + queue-microtask: 1.2.3 + /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: queue-microtask: 1.2.3 + /run-series@1.1.9: + resolution: {integrity: sha512-Arc4hUN896vjkqCYrUXquBFtRZdv1PfLbTYP71efP6butxyQ0kWpiNJyAgsxscmQg1cqvHY32/UCBzXedTpU2g==} + dev: true + + /rustbn.js@0.2.0: + resolution: {integrity: sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==} + /rw@1.3.3: resolution: {integrity: sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==} dev: false @@ -24081,6 +27254,9 @@ packages: has-symbols: 1.0.3 isarray: 2.0.5 + /safe-buffer@5.1.2: + resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + /safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} @@ -24112,8 +27288,25 @@ packages: /sax@1.3.0: resolution: {integrity: sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==} requiresBuild: true - dev: false - optional: true + + /sc-istanbul@0.4.6: + resolution: {integrity: sha512-qJFF/8tW/zJsbyfh/iT/ZM5QNHE3CXxtLJbZsL+CzdJLBsPD7SedJZoUA4d8iAcN2IoMp/Dx80shOOd2x96X/g==} + hasBin: true + dependencies: + abbrev: 1.0.9 + async: 1.5.2 + escodegen: 1.8.1 + esprima: 2.7.3 + glob: 5.0.15 + handlebars: 4.7.8 + js-yaml: 3.14.1 + mkdirp: 0.5.6 + nopt: 3.0.6 + once: 1.4.0 + resolve: 1.1.7 + supports-color: 3.2.3 + which: 1.3.1 + wordwrap: 1.0.0 /scheduler@0.17.0: resolution: {integrity: sha512-7rro8Io3tnCPuY4la/NuI5F2yfESpnfZyT6TtkXnSWVkcu0BCDJ+8gk5ozUaFaxpIyNuWAPXrH0yFcSi28fnDA==} @@ -24164,6 +27357,18 @@ packages: compute-scroll-into-view: 3.1.0 dev: false + /scrypt-js@3.0.1: + resolution: {integrity: sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==} + + /secp256k1@4.0.3: + resolution: {integrity: sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==} + engines: {node: '>=10.0.0'} + requiresBuild: true + dependencies: + elliptic: 6.5.4 + node-addon-api: 2.0.2 + node-gyp-build: 4.8.0 + /section-matter@1.0.0: resolution: {integrity: sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==} engines: {node: '>=4'} @@ -24172,6 +27377,10 @@ packages: kind-of: 6.0.3 dev: false + /seedrandom@3.0.5: + resolution: {integrity: sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==} + dev: true + /semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -24215,12 +27424,25 @@ packages: upper-case-first: 1.1.2 dev: true + /sentence-case@3.0.4: + resolution: {integrity: sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==} + dependencies: + no-case: 3.0.4 + tslib: 2.6.2 + upper-case-first: 2.0.2 + dev: false + /serialize-javascript@4.0.0: resolution: {integrity: sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==} dependencies: randombytes: 2.1.0 dev: false + /serialize-javascript@6.0.0: + resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==} + dependencies: + randombytes: 2.1.0 + /serialize-javascript@6.0.2: resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==} dependencies: @@ -24264,9 +27486,11 @@ packages: functions-have-names: 1.2.3 has-property-descriptors: 1.0.1 + /setimmediate@1.0.5: + resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} + /setprototypeof@1.2.0: resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} - dev: false /sha.js@2.4.11: resolution: {integrity: sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==} @@ -24274,7 +27498,12 @@ packages: dependencies: inherits: 2.0.4 safe-buffer: 5.2.1 - dev: false + + /sha1@1.1.1: + resolution: {integrity: sha512-dZBS6OrMjtgVkopB1Gmo4RQCDKiZsqcpAQpkV/aaj+FCrCg8r4I4qMkDPQjBgLIxlmu9k4nUbWq6ohXahOneYA==} + dependencies: + charenc: 0.0.2 + crypt: 0.0.2 /sharp@0.32.6: resolution: {integrity: sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==} @@ -24314,6 +27543,15 @@ packages: /shell-quote@1.8.1: resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==} + /shelljs@0.8.5: + resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==} + engines: {node: '>=4'} + hasBin: true + dependencies: + glob: 7.2.3 + interpret: 1.4.0 + rechoir: 0.6.2 + /shiki@0.14.7: resolution: {integrity: sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==} dependencies: @@ -24323,6 +27561,10 @@ packages: vscode-textmate: 8.0.0 dev: false + /shimmer@1.2.1: + resolution: {integrity: sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==} + dev: true + /side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: @@ -24377,6 +27619,11 @@ packages: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} + /slash@4.0.0: + resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==} + engines: {node: '>=12'} + dev: false + /slate-history@0.100.0(slate@0.101.5): resolution: {integrity: sha512-x5rUuWLNtH97hs9PrFovGgt3Qc5zkTm/5mcUB+0NR/TK923eLax4HsL6xACLHMs245nI6aJElyM1y6hN0y5W/Q==} peerDependencies: @@ -24513,6 +27760,14 @@ packages: is-fullwidth-code-point: 3.0.0 dev: false + /slice-ansi@4.0.0: + resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + astral-regex: 2.0.0 + is-fullwidth-code-point: 3.0.0 + /slice-ansi@5.0.0: resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} engines: {node: '>=12'} @@ -24549,14 +27804,13 @@ packages: dependencies: dot-case: 3.0.4 tslib: 2.6.2 - dev: true /socks-proxy-agent@8.0.2: resolution: {integrity: sha512-8zuqoLv1aP/66PHF5TqwJ7Czm3Yv32urJQHrVyhD7mmA6d61Zv8cIXQYPTWwmg6qlupnPvs/QKDmfa4P/qct2g==} engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) socks: 2.7.1 transitivePeerDependencies: - supports-color @@ -24568,6 +27822,57 @@ packages: ip: 2.0.0 smart-buffer: 4.2.0 + /solc@0.7.3(debug@4.3.4): + resolution: {integrity: sha512-GAsWNAjGzIDg7VxzP6mPjdurby3IkGCjQcM8GFYZT6RyaoUZKmMU6Y7YwG+tFGhv7dwZ8rmR4iwFDrrD99JwqA==} + engines: {node: '>=8.0.0'} + hasBin: true + dependencies: + command-exists: 1.2.9 + commander: 3.0.2 + follow-redirects: 1.15.5(debug@4.3.4) + fs-extra: 0.30.0 + js-sha3: 0.8.0 + memorystream: 0.3.1 + require-from-string: 2.0.2 + semver: 5.7.2 + tmp: 0.0.33 + transitivePeerDependencies: + - debug + + /solidity-comments-extractor@0.0.8: + resolution: {integrity: sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==} + dev: true + + /solidity-coverage@0.8.5(hardhat@2.19.4): + resolution: {integrity: sha512-6C6N6OV2O8FQA0FWA95FdzVH+L16HU94iFgg5wAFZ29UpLFkgNI/DRR2HotG1bC0F4gAc/OMs2BJI44Q/DYlKQ==} + hasBin: true + peerDependencies: + hardhat: ^2.11.0 + dependencies: + '@ethersproject/abi': 5.7.0 + '@solidity-parser/parser': 0.16.2 + chalk: 2.4.2 + death: 1.1.0 + detect-port: 1.5.1 + difflib: 0.2.4 + fs-extra: 8.1.0 + ghost-testrpc: 0.0.2 + global-modules: 2.0.0 + globby: 10.0.2 + hardhat: 2.19.4(ts-node@10.9.2)(typescript@5.3.3) + jsonschema: 1.4.1 + lodash: 4.17.21 + mocha: 10.2.0 + node-emoji: 1.11.0 + pify: 4.0.1 + recursive-readdir: 2.2.3 + sc-istanbul: 0.4.6 + semver: 7.5.4 + shelljs: 0.8.5 + web3-utils: 1.10.3 + transitivePeerDependencies: + - supports-color + /sonic-boom@2.8.0: resolution: {integrity: sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==} dependencies: @@ -24605,6 +27910,14 @@ packages: buffer-from: 1.1.2 source-map: 0.6.1 + /source-map@0.2.0: + resolution: {integrity: sha512-CBdZ2oa/BHhS4xj5DlhjWNHcan57/5YuvfdLf17iVmIpd9KRm+DFLmC6nBNj+6Ua7Kt3TmOjDpQT1aTYOQtoUA==} + engines: {node: '>=0.8.0'} + requiresBuild: true + dependencies: + amdefine: 1.0.1 + optional: true + /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} @@ -24682,6 +27995,10 @@ packages: /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + /sprintf-js@1.1.2: + resolution: {integrity: sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==} + dev: true + /srcset@4.0.0: resolution: {integrity: sha512-wvLeHgcVHKO8Sc/H/5lkGreJQVeYMm9rlmt8PuR1xE31rIuXhuzznUUqAt8MqLhB3MqJdFzlNAfpcWnxiFUcPw==} engines: {node: '>=12'} @@ -24699,6 +28016,12 @@ packages: escape-string-regexp: 2.0.0 dev: false + /stacktrace-parser@0.1.10: + resolution: {integrity: sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg==} + engines: {node: '>=6'} + dependencies: + type-fest: 0.7.1 + /standard-as-callback@2.1.0: resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==} dev: false @@ -24706,12 +28029,18 @@ packages: /statuses@2.0.1: resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} engines: {node: '>= 0.8'} - dev: false /std-env@3.7.0: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} dev: false + /stdin-discarder@0.1.0: + resolution: {integrity: sha512-xhV7w8S+bUwlPTb4bAOUQhv8/cSS5offJuX8GQGq32ONF0ZtDWKfkdomM3HMRA+LhX6um/FZ0COqlwsjD53LeQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + bl: 5.1.0 + dev: false + /stook@1.17.0: resolution: {integrity: sha512-Ps3/e4A+tS0+9ksKV/51qfZeXhV/7bBckY4g9s/SVH8fpljhk+fHXUcRfXVIFyHnzlju0TH8fZlgDfVK8QScYg==} dependencies: @@ -24758,10 +28087,20 @@ packages: engines: {node: '>=0.6.19'} dev: true + /string-format@2.0.0: + resolution: {integrity: sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==} + /string-hash@1.1.3: resolution: {integrity: sha512-kJUvRUFK49aub+a7T1nNE66EJbZBMnBgoC1UbCZ5n6bsZKBRga4KgBRTMn/pFkeCZSYtNeSyMxPDM0AXWELk2A==} dev: false + /string-width@2.1.1: + resolution: {integrity: sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==} + engines: {node: '>=4'} + dependencies: + is-fullwidth-code-point: 2.0.0 + strip-ansi: 4.0.0 + /string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -24813,6 +28152,11 @@ packages: define-properties: 1.2.1 es-abstract: 1.22.3 + /string_decoder@1.1.1: + resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} + dependencies: + safe-buffer: 5.1.2 + /string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} dependencies: @@ -24834,6 +28178,12 @@ packages: is-regexp: 1.0.0 dev: false + /strip-ansi@4.0.0: + resolution: {integrity: sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==} + engines: {node: '>=4'} + dependencies: + ansi-regex: 3.0.1 + /strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -24873,6 +28223,12 @@ packages: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} + /strip-hex-prefix@1.0.0: + resolution: {integrity: sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A==} + engines: {node: '>=6.5.0', npm: '>=3'} + dependencies: + is-hex-prefixed: 1.0.0 + /strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -24946,6 +28302,12 @@ packages: engines: {node: '>=14.0.0'} dev: false + /supports-color@3.2.3: + resolution: {integrity: sha512-Jds2VIYDrlp5ui7t8abHN2bjAu4LV/q4N2KivFPpGH0lrka0BMq/33AmECUXlKPcHigkNaqfXRENFju+rlcy+A==} + engines: {node: '>=0.8.0'} + dependencies: + has-flag: 1.0.0 + /supports-color@4.5.0: resolution: {integrity: sha512-ycQR/UbvI9xIlEdQT1TQqwoXtEldExbCEAJgRo5YXlmSKjv6ThHnP9/vwGa1gr19Gfw+LkFd7KqYMhzrRC5JYw==} engines: {node: '>=4'} @@ -24970,7 +28332,6 @@ packages: engines: {node: '>=10'} dependencies: has-flag: 4.0.0 - dev: false /supports-preserve-symlinks-flag@1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} @@ -25037,15 +28398,56 @@ packages: upper-case: 1.1.3 dev: true + /sync-request@6.1.0: + resolution: {integrity: sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==} + engines: {node: '>=8.0.0'} + dependencies: + http-response-object: 3.0.2 + sync-rpc: 1.3.6 + then-request: 6.0.2 + + /sync-rpc@1.3.6: + resolution: {integrity: sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw==} + dependencies: + get-port: 3.2.0 + /system-architecture@0.1.0: resolution: {integrity: sha512-ulAk51I9UVUyJgxlv9M6lFot2WP3e7t8Kz9+IS6D4rVba1tR9kON+Ey69f+1R4Q8cd45Lod6a4IcJIxnzGc/zA==} engines: {node: '>=18'} dev: false + /systeminformation@5.21.24: + resolution: {integrity: sha512-xQada8ByGGFoRXJaUptGgddn3i7IjtSdqNdCKzB8xkzsM7pHnfLYBWxkPdGzhZ0Z/l+W1yo+aZQZ74d2isj8kw==} + engines: {node: '>=8.0.0'} + os: [darwin, linux, win32, freebsd, openbsd, netbsd, sunos, android] + hasBin: true + requiresBuild: true + dev: true + optional: true + /tabbable@6.2.0: resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==} dev: false + /table-layout@1.0.2: + resolution: {integrity: sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==} + engines: {node: '>=8.0.0'} + dependencies: + array-back: 4.0.2 + deep-extend: 0.6.0 + typical: 5.2.0 + wordwrapjs: 4.0.1 + + /table@6.8.1: + resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} + engines: {node: '>=10.0.0'} + dependencies: + ajv: 8.12.0 + lodash.truncate: 4.4.2 + slice-ansi: 4.0.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + /tapable@2.2.1: resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} @@ -25168,6 +28570,22 @@ packages: /text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} + /then-request@6.0.2: + resolution: {integrity: sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA==} + engines: {node: '>=6.0.0'} + dependencies: + '@types/concat-stream': 1.6.1 + '@types/form-data': 0.0.33 + '@types/node': 8.10.66 + '@types/qs': 6.9.11 + caseless: 0.12.0 + concat-stream: 1.6.2 + form-data: 2.5.1 + http-basic: 8.1.3 + http-response-object: 3.0.2 + promise: 8.3.0 + qs: 6.11.2 + /thenify-all@1.6.0: resolution: {integrity: sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==} engines: {node: '>=0.8'} @@ -25198,6 +28616,10 @@ packages: resolution: {integrity: sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==} dev: false + /tiny-emitter@2.1.0: + resolution: {integrity: sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==} + dev: true + /tiny-inflate@1.0.3: resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==} dev: false @@ -25274,7 +28696,6 @@ packages: /toidentifier@1.0.1: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} - dev: false /tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} @@ -25306,11 +28727,27 @@ packages: resolution: {integrity: sha512-kloPhf1hq3JbCPOTYoOWDKxebWjNb2o/LKnNfkWhxVVisFFmMJPPdJeGoGmM+iRLyoXAR61e08Pb+vUXINg8aA==} dev: false + /ts-command-line-args@2.5.1: + resolution: {integrity: sha512-H69ZwTw3rFHb5WYpQya40YAX2/w7Ut75uUECbgBIsLmM+BNuYnxsltfyyLMxy6sEeKxgijLTnQtLd0nKd6+IYw==} + hasBin: true + dependencies: + chalk: 4.1.2 + command-line-args: 5.2.1 + command-line-usage: 6.1.3 + string-format: 2.0.0 + /ts-dedent@2.2.0: resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} engines: {node: '>=6.10'} dev: false + /ts-essentials@7.0.3(typescript@5.3.3): + resolution: {integrity: sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==} + peerDependencies: + typescript: '>=3.7.0' + dependencies: + typescript: 5.3.3 + /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} @@ -25364,12 +28801,31 @@ packages: minimist: 1.2.8 strip-bom: 3.0.0 + /tsconfig-paths@4.2.0: + resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} + engines: {node: '>=6'} + dependencies: + json5: 2.2.3 + minimist: 1.2.8 + strip-bom: 3.0.0 + dev: true + /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + /tslib@1.9.3: + resolution: {integrity: sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==} + dev: true + + /tslib@2.4.0: + resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} + /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + /tsort@0.0.1: + resolution: {integrity: sha512-Tyrf5mxF8Ofs1tNoxA13lFeZ2Zrbd6cKbuH3V+MQ5sb6DtBj5FjrXVsRWT8YvNAQTqNoz66dz1WsbigI22aEnw==} + /tsup@7.2.0(ts-node@10.9.2)(typescript@5.2.2): resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==} engines: {node: '>=16.14'} @@ -25389,7 +28845,7 @@ packages: bundle-require: 4.0.2(esbuild@0.18.20) cac: 6.7.14 chokidar: 3.5.3 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) esbuild: 0.18.20 execa: 5.1.1 globby: 11.1.0 @@ -25425,7 +28881,7 @@ packages: bundle-require: 4.0.2(esbuild@0.18.20) cac: 6.7.14 chokidar: 3.5.3 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) esbuild: 0.18.20 execa: 5.1.1 globby: 11.1.0 @@ -25548,12 +29004,41 @@ packages: domino: 2.1.6 dev: false + /tv4@1.3.0: + resolution: {integrity: sha512-afizzfpJgvPr+eDkREK4MxJ/+r8nEEHcmitwgnPUqpaP+FpwQyadnxNoSACbgc/b1LsZYtODGoPiFxQrgJgjvw==} + engines: {node: '>= 0.8.0'} + dev: true + + /tweetnacl-util@0.15.1: + resolution: {integrity: sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw==} + + /tweetnacl@1.0.3: + resolution: {integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==} + + /tx2@1.0.5: + resolution: {integrity: sha512-sJ24w0y03Md/bxzK4FU8J8JveYYUbSs2FViLJ2D/8bytSiyPRbuE3DyL/9UKYXTZlV3yXq0L8GLlhobTnekCVg==} + requiresBuild: true + dependencies: + json-stringify-safe: 5.0.1 + dev: true + optional: true + + /type-check@0.3.2: + resolution: {integrity: sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==} + engines: {node: '>= 0.8.0'} + dependencies: + prelude-ls: 1.1.2 + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} dependencies: prelude-ls: 1.2.1 + /type-detect@4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} + engines: {node: '>=4'} + /type-fest@0.12.0: resolution: {integrity: sha512-53RyidyjvkGpnWPMF9bQgFtWp+Sl8O2Rp13VavmJgfAP9WWG6q6TkrKU8iyJdnwnfgHI6k2hTlgqH4aSdjoTbg==} engines: {node: '>=10'} @@ -25587,6 +29072,10 @@ packages: engines: {node: '>=8'} dev: true + /type-fest@0.7.1: + resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} + engines: {node: '>=8'} + /type-fest@0.8.1: resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} engines: {node: '>=8'} @@ -25614,6 +29103,26 @@ packages: mime-types: 2.1.35 dev: false + /typechain@8.3.2(typescript@5.3.3): + resolution: {integrity: sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q==} + hasBin: true + peerDependencies: + typescript: '>=4.3.0' + dependencies: + '@types/prettier': 2.7.3 + debug: 4.3.4(supports-color@8.1.1) + fs-extra: 7.0.1 + glob: 7.1.7 + js-sha3: 0.8.0 + lodash: 4.17.21 + mkdirp: 1.0.4 + prettier: 2.8.8 + ts-command-line-args: 2.5.1 + ts-essentials: 7.0.3(typescript@5.3.3) + typescript: 5.3.3 + transitivePeerDependencies: + - supports-color + /typed-array-buffer@1.0.0: resolution: {integrity: sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==} engines: {node: '>= 0.4'} @@ -25648,12 +29157,20 @@ packages: for-each: 0.3.3 is-typed-array: 1.1.12 + /typed-function@4.1.1: + resolution: {integrity: sha512-Pq1DVubcvibmm8bYcMowjVnnMwPVMeh0DIdA8ad8NZY2sJgapANJmiigSUwlt+EgXxpfIv8MWrQXTIzkfYZLYQ==} + engines: {node: '>= 14'} + dev: true + /typedarray-to-buffer@3.1.5: resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} dependencies: is-typedarray: 1.0.0 dev: false + /typedarray@0.0.6: + resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} + /typescript@5.2.2: resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} engines: {node: '>=14.17'} @@ -25664,6 +29181,14 @@ packages: engines: {node: '>=14.17'} hasBin: true + /typical@4.0.0: + resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} + engines: {node: '>=8'} + + /typical@5.2.0: + resolution: {integrity: sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==} + engines: {node: '>=8'} + /ua-parser-js@1.0.37: resolution: {integrity: sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==} dev: false @@ -25681,7 +29206,6 @@ packages: engines: {node: '>=0.8.0'} hasBin: true requiresBuild: true - dev: true optional: true /uhyphen@0.2.0: @@ -25720,6 +29244,12 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + /undici@5.28.2: + resolution: {integrity: sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==} + engines: {node: '>=14.0'} + dependencies: + '@fastify/busboy': 2.1.0 + /unenv@1.9.0: resolution: {integrity: sha512-QKnFNznRxmbOF1hDgzpqrlIf6NC5sbZ2OJ+5Wl3OX8uM+LUJXbj4TXvLJCtwbPTmbMHCLIz6JLKNinNsMShK9g==} dependencies: @@ -25943,7 +29473,6 @@ packages: /unpipe@1.0.0: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} - dev: false /unplugin@1.6.0: resolution: {integrity: sha512-BfJEpWBu3aE/AyHx8VaNE/WgouoQxgH9baAiH82JjX8cqVyi3uJQstqwD5J+SZxIK326SZIhsSZlALXVBCknTQ==} @@ -26059,10 +29588,22 @@ packages: upper-case: 1.1.3 dev: true + /upper-case-first@2.0.2: + resolution: {integrity: sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==} + dependencies: + tslib: 2.6.2 + dev: false + /upper-case@1.1.3: resolution: {integrity: sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==} dev: true + /upper-case@2.0.2: + resolution: {integrity: sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==} + dependencies: + tslib: 2.6.2 + dev: false + /uqr@0.1.2: resolution: {integrity: sha512-MJu7ypHq6QasgF5YRTjqscSzQp/W11zoUk6kvmlH+fmWEs63Y0Eib13hYFwAzagRJcVY8WVnlV+eBDUGMJ5IbA==} dev: false @@ -26194,6 +29735,9 @@ packages: node-gyp-build: 4.8.0 dev: false + /utf8@3.0.0: + resolution: {integrity: sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==} + /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -26217,10 +29761,15 @@ packages: engines: {node: '>= 0.4.0'} dev: false + /uuid@3.4.0: + resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} + deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. + hasBin: true + dev: true + /uuid@8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true - dev: false /uuid@9.0.1: resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} @@ -26373,7 +29922,6 @@ packages: - bufferutil - utf-8-validate - zod - dev: false /vite-compatible-readable-stream@3.6.1: resolution: {integrity: sha512-t20zYkrSf868+j/p31cRIGN28Phrjm3nRSLR2fyc2tiWi4cZGVdv68yNlwnIINTkMTmPoMiSlc0OadaO7DXZaQ==} @@ -26384,6 +29932,16 @@ packages: util-deprecate: 1.0.2 dev: false + /vizion@2.2.1: + resolution: {integrity: sha512-sfAcO2yeSU0CSPFI/DmZp3FsFE9T+8913nv1xWBOyzODv13fwkn6Vl7HqxGpkr9F608M+8SuFId3s+BlZqfXww==} + engines: {node: '>=4.0'} + dependencies: + async: 2.6.4 + git-node-fs: 1.0.0(js-git@0.7.8) + ini: 1.3.8 + js-git: 0.7.8 + dev: true + /vscode-oniguruma@1.7.0: resolution: {integrity: sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==} dev: false @@ -26471,10 +30029,28 @@ packages: resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==} dev: false + /web-streams-polyfill@3.3.2: + resolution: {integrity: sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==} + engines: {node: '>= 8'} + dev: false + /web-worker@1.3.0: resolution: {integrity: sha512-BSR9wyRsy/KOValMgd5kMyr3JzpdeoR9KVId8u5GVlTTAtNChlsE4yTxeY7zMdNSyOmoKBv8NH2qeRY9Tg+IaA==} dev: false + /web3-utils@1.10.3: + resolution: {integrity: sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==} + engines: {node: '>=8.0.0'} + dependencies: + '@ethereumjs/util': 8.1.0 + bn.js: 5.2.1 + ethereum-bloom-filters: 1.0.10 + ethereum-cryptography: 2.1.3 + ethjs-unit: 0.1.6 + number-to-bn: 1.7.0 + randombytes: 2.1.0 + utf8: 3.0.0 + /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: false @@ -26627,9 +30203,19 @@ packages: string-width: 4.2.3 dev: false + /word-wrap@1.2.5: + resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} + engines: {node: '>=0.10.0'} + /wordwrap@1.0.0: resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} - dev: true + + /wordwrapjs@4.0.1: + resolution: {integrity: sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==} + engines: {node: '>=8.0.0'} + dependencies: + reduce-flatten: 2.0.0 + typical: 5.2.0 /workbox-background-sync@6.6.0: resolution: {integrity: sha512-jkf4ZdgOJxC9u2vztxLuPT/UjlH7m/nWRQ/MgGL0v8BJHoZdVGJd18Kck+a0e55wGXdqyHO+4IQTk0685g4MUw==} @@ -26795,6 +30381,9 @@ packages: workbox-core: 6.6.0 dev: false + /workerpool@6.2.1: + resolution: {integrity: sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==} + /wrap-ansi@6.2.0: resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} engines: {node: '>=8'} @@ -26822,6 +30411,18 @@ packages: /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + /ws@7.4.6: + resolution: {integrity: sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + /ws@7.5.9: resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} engines: {node: '>=8.3.0'} @@ -26833,7 +30434,6 @@ packages: optional: true utf-8-validate: optional: true - dev: false /ws@8.13.0: resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} @@ -26846,7 +30446,6 @@ packages: optional: true utf-8-validate: optional: true - dev: false /ws@8.16.0(bufferutil@4.0.8)(utf-8-validate@5.0.10): resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==} @@ -26864,6 +30463,18 @@ packages: utf-8-validate: 5.0.10 dev: false + /ws@8.5.0: + resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + /xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} @@ -26902,6 +30513,14 @@ packages: resolution: {integrity: sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==} engines: {node: '>= 14'} + /yamljs@0.3.0: + resolution: {integrity: sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==} + hasBin: true + dependencies: + argparse: 1.0.10 + glob: 7.2.3 + dev: true + /yargs-parser@18.1.3: resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==} engines: {node: '>=6'} @@ -26909,15 +30528,27 @@ packages: camelcase: 5.3.1 decamelize: 1.2.0 + /yargs-parser@20.2.4: + resolution: {integrity: sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==} + engines: {node: '>=10'} + /yargs-parser@20.2.9: resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} engines: {node: '>=10'} - dev: true /yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} + /yargs-unparser@2.0.0: + resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==} + engines: {node: '>=10'} + dependencies: + camelcase: 6.3.0 + decamelize: 4.0.0 + flat: 5.0.2 + is-plain-obj: 2.1.0 + /yargs@15.4.1: resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==} engines: {node: '>=8'} @@ -26934,6 +30565,18 @@ packages: y18n: 4.0.3 yargs-parser: 18.1.3 + /yargs@16.2.0: + resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} + engines: {node: '>=10'} + dependencies: + cliui: 7.0.4 + escalade: 3.1.1 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 20.2.9 + /yargs@17.6.0: resolution: {integrity: sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==} engines: {node: '>=12'} @@ -26973,6 +30616,11 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} + /yocto-queue@1.0.0: + resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} + engines: {node: '>=12.20'} + dev: false + /yoga-layout-prebuilt@1.10.0: resolution: {integrity: sha512-YnOmtSbv4MTf7RGJMK0FvZ+KD8OEe/J5BNnR0GHhD8J/XcG/Qvxgszm0Un6FTHWW4uHlTgP0IztiXQnGyIR45g==} engines: {node: '>=8'} @@ -26984,9 +30632,17 @@ packages: resolution: {integrity: sha512-tT/oChyDXelLo2A+UVnlW9GU7CsvFMaEnd9kVFsaiCQonFAXd3xrHhkLYu+suwwosrAEQ746xBU+HvYtm1Zs2Q==} dev: false + /zksync-web3@0.14.4(ethers@5.7.2): + resolution: {integrity: sha512-kYehMD/S6Uhe1g434UnaMN+sBr9nQm23Ywn0EUP5BfQCsbjcr3ORuS68PosZw8xUTu3pac7G6YMSnNHk+fwzvg==} + deprecated: This package has been deprecated in favor of zksync-ethers@5.0.0 + peerDependencies: + ethers: ^5.7.0 + dependencies: + ethers: 5.7.2 + dev: false + /zod@3.22.4: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} - dev: false /zustand@3.7.2(react@18.2.0): resolution: {integrity: sha512-PIJDIZKtokhof+9+60cpockVOq05sJzHCriyvaLBmEJixseQ1a5Kdov6fWZfWOu5SK9c+FhH1jU0tntLxRJYMA==}